costin 00/12/27 09:02:06 Modified: src/share/org/apache/tomcat/context ErrorHandler.java Log: Fixed ErrorHandler - showDebugInfo was removed from ContextManager as an "explicit" property. Larry - we can add it back, I just wanted to test the setProperty mechanism. The fix also allow contexts to override the setting in context manager - you can set it now at context level. What's interesting is that it does that without any special code in core - any new attributes can be added to <context > and <contextManager> tags. We should add properties to Context and ContextManager only if they are very generic ( like "home" ). Another method to do the same thing is to use per/context interceptors, or settings on the interceptor ( for example showDebugInfo="true" on the error handler ). This is better if the attribute is specific to a particular module ( like session saving in a file ). For showDebugInfo, it's likely that other modules will use it. Revision Changes Path 1.14 +41 -16 jakarta-tomcat/src/share/org/apache/tomcat/context/ErrorHandler.java Index: ErrorHandler.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/context/ErrorHandler.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- ErrorHandler.java 2000/12/20 15:20:21 1.13 +++ ErrorHandler.java 2000/12/27 17:02:06 1.14 @@ -102,13 +102,32 @@ { if( ctx.getHost() == null && ctx.getPath().equals("")) rootContext = ctx; - ctx.addServlet( new ExceptionHandler(this)); - ctx.addServlet( new StatusHandler(this)); + boolean showDebugInfo=true; + ContextManager cm=ctx.getContextManager(); + String dI=cm.getProperty( "showDebugInfo" ); + if( dI!=null && ( dI.equalsIgnoreCase("no") || + dI.equalsIgnoreCase("false"))) { + showDebugInfo=false; + } + + // override with per/context setting + dI=ctx.getProperty( "showDebugInfo" ); + if( dI!=null && ( dI.equalsIgnoreCase("no") || + dI.equalsIgnoreCase("false"))) { + showDebugInfo=false; + } + if( dI!=null && ( dI.equalsIgnoreCase("yes") || + dI.equalsIgnoreCase("true"))) { + showDebugInfo=true; + } + + ctx.addServlet( new ExceptionHandler(this, showDebugInfo)); + ctx.addServlet( new StatusHandler(this, showDebugInfo)); // Default status handlers ctx.addServlet( new RedirectHandler(this)); ctx.addErrorPage( "302", "tomcat.redirectHandler"); - ctx.addServlet( new NotFoundHandler(this)); + ctx.addServlet( new NotFoundHandler(this, showDebugInfo)); ctx.addErrorPage( "404", "tomcat.notFoundHandler"); } @@ -330,11 +349,13 @@ static StringManager sm=StringManager. getManager("org.apache.tomcat.resources"); int sbNote=0; + boolean showDebugInfo=true; - NotFoundHandler(BaseInterceptor bi) { + NotFoundHandler(BaseInterceptor bi, boolean showDebugInfo) { // setOrigin( Handler.ORIGIN_INTERNAL ); name="tomcat.notFoundHandler"; setModule(bi); + this.showDebugInfo=showDebugInfo; } public void doService(Request req, Response res) @@ -376,7 +397,7 @@ .append( requestURI ) .append("\r\n"); - if ( null != requestURI && contextM.isShowDebugInfo() ) { + if ( null != requestURI && showDebugInfo ) { buf.append("<br><br>\r\n<b>") .append(sm.getString("defaulterrorpage.notfoundrequest")) .append("</b> ") @@ -400,11 +421,13 @@ static StringManager sm=StringManager. getManager("org.apache.tomcat.resources"); int sbNote=0; - - ExceptionHandler(BaseInterceptor bi) { + boolean showDebugInfo=true; + + ExceptionHandler(BaseInterceptor bi, boolean showDebugInfo) { // setOrigin( Handler.ORIGIN_INTERNAL ); name="tomcat.exceptionHandler"; setModule( bi ); + this.showDebugInfo=showDebugInfo; } public void doService(Request req, Response res) @@ -440,7 +463,7 @@ // only include <head>...<body> if reset was successful if (bufReset) { buf.append("<head><title>"); - if( null != errorURI && contextM.isShowDebugInfo() ) { + if( null != errorURI && showDebugInfo ) { buf.append(sm.getString("defaulterrorpage.includedservlet") ) .append(" "); } else { @@ -450,7 +473,7 @@ .append("</title></head>\r\n<body>\r\n"); } buf.append("<h1>"); - if( null != errorURI && contextM.isShowDebugInfo() ) { + if( null != errorURI && showDebugInfo ) { buf.append(sm.getString("defaulterrorpage.includedservlet") ). append(" "); } else { @@ -466,7 +489,7 @@ .append(req.requestURI().toString()) .append("</h2>"); - if ( null != errorURI && contextM.isShowDebugInfo()) { + if ( null != errorURI && showDebugInfo ) { buf.append("\r\n<h2>") .append(sm.getString("defaulterrorpage.errorlocation")) .append(" ") @@ -474,7 +497,7 @@ .append("</h2>"); } - if (contextM.isShowDebugInfo()) { + if (showDebugInfo) { buf.append("<b>") .append(sm.getString("defaulterrorpage.internalservleterror")); buf.append("</b><br>\r\n<pre>"); @@ -503,11 +526,13 @@ static StringManager sm=StringManager. getManager("org.apache.tomcat.resources"); int sbNote=0; - - StatusHandler(BaseInterceptor bi) { + boolean showDebugInfo=true; + + StatusHandler(BaseInterceptor bi, boolean showDebugInfo) { //setOrigin( Handler.ORIGIN_INTERNAL ); name="tomcat.statusHandler"; setModule( bi ); + this.showDebugInfo=showDebugInfo; } // We don't want interceptors called for redirect @@ -540,7 +565,7 @@ // only include <head>...<body> if reset was successful if (bufReset) { buf.append("<head><title>"); - if( null != errorURI && contextM.isShowDebugInfo() ) { + if( null != errorURI && showDebugInfo ) { buf.append(sm.getString("defaulterrorpage.includedservlet") ) .append(" "); } else { @@ -550,7 +575,7 @@ .append("</title></head>\r\n<body>\r\n"); } buf.append("<h1>"); - if( null != errorURI && contextM.isShowDebugInfo() ) { + if( null != errorURI && showDebugInfo ) { buf.append(sm.getString("defaulterrorpage.includedservlet") ) .append(" "); } else { @@ -566,7 +591,7 @@ .append(req.requestURI().toString()) .append("</h2>"); - if ( sc >= 400 && errorURI != null && contextM.isShowDebugInfo()) { + if ( sc >= 400 && errorURI != null && showDebugInfo) { buf.append("\r\n<h2>") .append(sm.getString("defaulterrorpage.errorlocation")) .append(" ")