tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@locus.apache.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/context ErrorHandler.java
Date Thu, 02 Nov 2000 21:17:43 GMT
costin      00/11/02 13:17:41

  Modified:    src/share/org/apache/tomcat/context ErrorHandler.java
  Log:
  Removed ContextManger.getDefaultContext().
  
  The method doesn't work with virtual hosts, and it wasn't used in any
  other place then ErrorHandler.
  
  Any Context that needs the "/" webapps of the "default" host can
  get it in the addContext() hook, no need to keep it explicitely in core.
  
  Revision  Changes    Path
  1.2       +17 -10    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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ErrorHandler.java	2000/10/08 01:02:25	1.1
  +++ ErrorHandler.java	2000/11/02 21:17:38	1.2
  @@ -79,7 +79,8 @@
    * @author Costin Manolache
    */
   public final class ErrorHandler extends BaseInterceptor {
  -
  +    private Context rootContext=null;
  +    
       public ErrorHandler() {
       }
   
  @@ -91,6 +92,8 @@
       public void addContext( ContextManager cm, Context ctx)
   	throws TomcatException
       {
  +	if( ctx.getHost() == null && ctx.getPath().equals(""))
  +	    rootContext = ctx;
       }
   
       /** Add default error handlers
  @@ -108,11 +111,15 @@
   	ctx.addErrorPage( "404", "tomcat.notFoundHandler");
       }
   
  -
       public int handleError( Request req, Response res, Throwable t ) {
   	ContextManager cm=req.getContextManager();
   	Context ctx = req.getContext();
  -	if(ctx==null) ctx=cm.getDefaultContext();
  +	if(ctx==null) {
  +	    // that happens only if the request can't pass contextMap
  +	    // hook. The reason for that is a malformed request, or any
  +	    // other error.
  +	    ctx=rootContext;
  +	}
   
   	if( t==null ) {
   	    handleStatusImpl( cm, ctx, req, res, res.getStatus() );
  @@ -264,9 +271,9 @@
   	Response res1=new Response();
   	cm.initRequest( req1, res1 );
   
  -	req1.setRequestURI( ctx.getPath() + path );
  +	req1.requestURI().setString( ctx.getPath() + path );
   	cm.processRequest( req1 );
  -	return req1.getWrapper();
  +	return req1.getHandler();
       }
   
       /** Handle the case of error handler generating an error or special status
  @@ -311,7 +318,7 @@
   	    getAttribute("javax.servlet.include.request_uri");
   
   	if (requestURI == null) {
  -	    requestURI = req.getRequestURI();
  +	    requestURI = req.requestURI().toString();
   	}
   
   	if( sbNote==0 ) {
  @@ -396,7 +403,7 @@
   	// More info - where it happended"
   	buf.append("<h2>")
   	    .append(sm.getString("defaulterrorpage.location"))
  -	    .append(req.getRequestURI())
  +	    .append(req.requestURI().toString())
   	    .append("</h2>");
   
   	buf.append("<b>")
  @@ -466,7 +473,7 @@
   	// More info - where it happended"
   	buf.append("<h2>")
   	    .append(sm.getString("defaulterrorpage.location"))
  -	    .append(req.getRequestURI())
  +	    .append(req.requestURI().toString())
   	    .append("</h2>");
   
   	buf.append("<b>")
  @@ -556,9 +563,9 @@
   
       static String getRequestURL( Request req )  {
    	StringBuffer url = new StringBuffer ();
  -	String scheme = req.getScheme ();
  +	String scheme = req.scheme().toString();
   	int port = req.getServerPort ();
  -	String urlPath = req.getRequestURI();
  +	String urlPath = req.requestURI().toString();
   	
   	url.append (scheme);		// http, https
   	url.append ("://");
  
  
  

Mime
View raw message