tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lar...@locus.apache.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core ContextManager.java
Date Thu, 14 Sep 2000 00:40:16 GMT
larryi      00/09/13 17:40:16

  Modified:    src/share/org/apache/tomcat/core ContextManager.java
  Log:
  Port Tomcat 3.2 changes to handleError and handleStatus.
  
  Revision  Changes    Path
  1.129     +32 -4     jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java
  
  Index: ContextManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java,v
  retrieving revision 1.128
  retrieving revision 1.129
  diff -u -r1.128 -r1.129
  --- ContextManager.java	2000/09/02 22:51:31	1.128
  +++ ContextManager.java	2000/09/14 00:40:16	1.129
  @@ -954,8 +954,6 @@
   	String errorPath=null;
   	Handler errorServlet=null;
   
  -	res.resetBuffer();
  -
   	if( code==0 )
   	    code=res.getStatus();
   	else
  @@ -975,16 +973,27 @@
   	errorPath = ctx.getErrorPage( code );
   	if( errorPath != null ) {
   	    errorServlet=getHandlerForPath( ctx, errorPath );
  +
  +	    // Make sure Jsps will work
  +	    req.setAttribute( "javax.servlet.include.request_uri",
  +				  ctx.getPath()  + "/" + errorPath );
  +	    req.setAttribute( "javax.servlet.include.servlet_path", errorPath );
   	}
   
  -	if( errorServlet==null )
  +	boolean isDefaultHandler = false;
  +	if( errorServlet==null ) {
   	    errorServlet=ctx.getServletByName( "tomcat.statusHandler");
  +	    isDefaultHandler = true;
  +	}
   
   	if (errorServlet == null) {
   	    ctx.log( "Handler errorServlet is null! errorPath:" + errorPath);
   	    return;
   	}
   
  +	if (!isDefaultHandler)
  +	    res.resetBuffer();
  +
   	req.setAttribute("javax.servlet.error.status_code",new Integer( code));
   	req.setAttribute("tomcat.servlet.error.request", req);
   
  @@ -1047,15 +1056,34 @@
   
   	if( errorPath != null ) {
   	    errorServlet=getHandlerForPath( ctx, errorPath );
  +
  +	    // Make sure Jsps will work
  +	    req.setAttribute( "javax.servlet.include.request_uri",
  +				  ctx.getPath()  + "/" + errorPath );
  +	    req.setAttribute( "javax.servlet.include.servlet_path", errorPath );
   	}
   
  -	if( errorLoop( ctx, req ) || errorServlet==null) ;
  +	boolean isDefaultHandler = false;
  +	if( errorLoop( ctx, req ) || errorServlet==null) {
   	    errorServlet = ctx.getServletByName("tomcat.exceptionHandler");
  +	    isDefaultHandler = true;
  +	}
   
  +	if (errorServlet == null) {
  +	    ctx.log( "Handler errorServlet is null! errorPath:" + errorPath);
  +	    return;
  +	}
  +
  +	if (!isDefaultHandler)
  +	    res.resetBuffer();
  +
   	req.setAttribute("javax.servlet.error.exception_type", t.getClass());
   	req.setAttribute("javax.servlet.error.message", t.getMessage());
   	req.setAttribute("tomcat.servlet.error.throwable", t);
   	req.setAttribute("tomcat.servlet.error.request", req);
  +
  +	if( debug>0 )
  +	    ctx.log( "Handler " + errorServlet + " " + errorPath);
   
   	errorServlet.service( req, res );
       }
  
  
  

Mime
View raw message