tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@apache.org
Subject cvs commit: jakarta-tomcat/src/facade22/org/apache/tomcat/facade HttpServletRequestFacade.java JspInterceptor.java
Date Tue, 06 Feb 2001 06:33:35 GMT
costin      01/02/05 22:33:35

  Modified:    src/facade22/org/apache/tomcat/facade
                        HttpServletRequestFacade.java JspInterceptor.java
  Log:
  ServletRequestFacade will now use Parameters. It'll also implement the
  API requirements about when and how the POST parameters are read.
  
  JspInterceptor will now deal with jsp_precompile.
  
  Revision  Changes    Path
  1.17      +27 -3     jakarta-tomcat/src/facade22/org/apache/tomcat/facade/HttpServletRequestFacade.java
  
  Index: HttpServletRequestFacade.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/facade22/org/apache/tomcat/facade/HttpServletRequestFacade.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- HttpServletRequestFacade.java	2001/01/01 00:17:22	1.16
  +++ HttpServletRequestFacade.java	2001/02/06 06:33:35	1.17
  @@ -94,6 +94,8 @@
       private boolean usingStream = false;
       private boolean usingReader = false;
   
  +    private boolean parametersProcessed=false;
  +    
       /** Not public 
        */
       HttpServletRequestFacade(Request request) {
  @@ -106,6 +108,7 @@
       void recycle() {
   	usingReader=false;
   	usingStream=false;
  +	parametersProcessed=false;
   	if( sessionFacade!=null) sessionFacade.recycle();
   	if( isFacade != null ) isFacade.recycle();
   	isFacadeInitialized=false;
  @@ -230,15 +233,36 @@
       /** Adapter: Request doesn't deal with this servlet convention
        */
       public String getParameter(String name) {
  -        return request.getParameter( name );
  +	if( ! parametersProcessed ) {
  +	    request.parameters().handleQueryParameters();
  +	    if( request.method().equals("POST")) {
  +		request.handlePostParameters();
  +	    }
  +	    parametersProcessed=true;
  +	}
  +        return request.parameters().getParameter( name );
       }
   
       public String[] getParameterValues(String name) {
  -        return request.getParameterValues(name);
  +	if( ! parametersProcessed ) {
  +	    request.parameters().handleQueryParameters();
  +	    if( request.method().equals("POST")) {
  +		request.handlePostParameters();
  +	    }
  +	    parametersProcessed=true;
  +	}
  +        return request.parameters().getParameterValues(name);
       }
   
       public Enumeration getParameterNames() {
  -        return request.getParameterNames();
  +	if( ! parametersProcessed ) {
  +	    request.parameters().handleQueryParameters();
  +	    if( request.method().equals("POST")) {
  +		request.handlePostParameters();
  +	    }
  +	    parametersProcessed=true;
  +	}
  +        return request.parameters().getParameterNames();
       }
       
       public String getPathInfo() {
  
  
  
  1.13      +62 -0     jakarta-tomcat/src/facade22/org/apache/tomcat/facade/JspInterceptor.java
  
  Index: JspInterceptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/facade22/org/apache/tomcat/facade/JspInterceptor.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- JspInterceptor.java	2001/02/06 02:46:25	1.12
  +++ JspInterceptor.java	2001/02/06 06:33:35	1.13
  @@ -279,6 +279,8 @@
   	    }
   
   	    jspServlet.setServletClassName(jspServletCN);
  +	} else {
  +	    ctx.addServlet( new JspPrecompileH());
   	}
       }
   
  @@ -373,6 +375,26 @@
   		return 0; // not a jsp
   	}
   
  +	// if it's a jsp_precompile request, don't execute - just
  +	// compile ( if needed ). Since we'll compile the jsp on
  +	// the first request the only special thing is to not
  +	// execute the jsp if jsp_precompile param is in parameters.
  +	String qString=req.queryString().toString();
  +	// look for ?jsp_precompile or &jsp_precompile
  +
  +	// quick test to see if we need to worry about params
  +	// ( preserve lazy eval for parameters )
  +	boolean pre_compile=false;
  +	int i=(qString==null) ? -1: qString.indexOf( "jsp_precompile" );
  +	if( i>= 0 ) {
  +	    // Probably we are in the problem case. 
  +	    req.parameters().handleQueryParameters();
  +	    String p=req.parameters().getParameter( "jsp_precompile");
  +	    if( p==null || p.equalsIgnoreCase("true")) {
  +		pre_compile=true;
  +	    }
  +	}
  +	
   	// Each .jsp file is compiled to a servlet, and will
   	// have a dependency to check if it's expired
   	Dependency dep= handler.getServletInfo().getDependency();
  @@ -386,6 +408,18 @@
   	// we need to compile... ( or find previous .class )
   	JasperLiaison liasion=new JasperLiaison(getLog(), debug);
   	liasion.processJspFile(req, jspFile, handler, args);
  +
  +	if( pre_compile ) {
  +	    // we may have compiled the page ( if needed ), but
  +	    // we can't execute it. The handler will just
  +	    // report that we detected the trick.
  +
  +	    // Future: detail information about compile results
  +	    // and if indeed we had to do something or not
  +	    req.setHandler(  ctx.
  +			     getServletByName( "tomcat.jspPrecompileHandler"));
  +	}
  +	
   	return 0;
       }
   
  @@ -438,6 +472,34 @@
       }
   
   }
  +
  +// -------------------- Jsp_precompile handler --------------------
  +
  +/** What to do for jsp precompile
  + */
  +class JspPrecompileH extends Handler {
  +    static StringManager sm=StringManager.
  +	getManager("org.apache.tomcat.resources");
  +    
  +    JspPrecompileH() {
  +	name="tomcat.jspPrecompileHandler";
  +    }
  +
  +    public void doService(Request req, Response res)
  +	throws Exception
  +    {
  +	res.setContentType("text/html");	
  +
  +	String msg="<h1>Jsp Precompile Done</h1>";
  +
  +	res.setContentLength(msg.length());
  +
  +	res.getBuffer().write( msg );
  +    }
  +}
  +
  +
  +
   
   // -------------------- The main Jasper Liaison --------------------
   
  
  
  

Mime
View raw message