tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gl...@apache.org
Subject cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet JspServlet.java
Date Tue, 30 Apr 2002 13:28:24 GMT
glenn       02/04/30 06:28:24

  Modified:    jasper2/src/share/org/apache/jasper/servlet JspServlet.java
  Log:
  Minor refactoring.  Remove commented out and unused code.
  Move obtaining the classpath from loadIfNecessary to init(),
  minor performance improvement.
  Factor out the loadIfNecessary method, it only had a few lines
  of code left in it.
  
  Revision  Changes    Path
  1.8       +16 -58    jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet/JspServlet.java
  
  Index: JspServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet/JspServlet.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- JspServlet.java	29 Apr 2002 23:03:06 -0000	1.7
  +++ JspServlet.java	30 Apr 2002 13:28:24 -0000	1.8
  @@ -167,38 +167,8 @@
   		throw new JasperException(ex);
   	    }
   	    theServlet.init(JspServlet.this.config);
  -/*	Shouldn't be needed after switching to URLClassLoader
  -	    if (theServlet instanceof HttpJspBase)  {
  -                HttpJspBase h = (HttpJspBase) theServlet;
  -                h.setClassLoader(JspServlet.this.parentClassLoader);
  -	    }
  -*/
   	}
  -	
  -	private void loadIfNecessary(HttpServletRequest req, HttpServletResponse res) 
  -            throws JasperException, ServletException, FileNotFoundException 
  -        {
  -            // First try context attribute; if that fails then use the 
  -            // classpath init parameter. 
  -
  -            // Should I try to concatenate them if both are non-null?
  -
  -            String cp = (String) context.getAttribute(Constants.SERVLET_CLASSPATH);
  -
  -            String accordingto;
  -
  -            if (cp == null || cp.equals("")) {
  -                accordingto = "according to the init parameter";
  -                cp = options.getClassPath();
  -            } else 
  -                accordingto = "according to the Servlet Engine";
  -            
  -            if (loadJSP(this, jspUri, cp, isErrorPage, req, res) 
  -                    || theServlet == null) {
  -                load();
  -            }
  -	}
  -	
  +
   	public void service(HttpServletRequest request, 
   			    HttpServletResponse response,
   			    boolean precompile)
  @@ -213,7 +183,11 @@
                            Constants.getString("jsp.error.unavailable"));
                   }
   
  -                loadIfNecessary(request, response);
  +                if (loadJSP(this, jspUri, classpath,
  +                            isErrorPage, request, response)
  +                        || theServlet == null) {
  +                    load();
  +                }
   
   		// If a page is to only to be precompiled return.
   		if (precompile)
  @@ -286,9 +260,9 @@
       protected URLClassLoader parentClassLoader;
       protected ServletEngine engine;
       protected String serverInfo;
  -    private PermissionCollection permissionCollection = null;
  -    private CodeSource codeSource = null;
  -
  +    private PermissionCollection permissionCollection;
  +    private CodeSource codeSource;
  +    private String classpath;
       static boolean firstTime = true;
   
       public void init(ServletConfig config)
  @@ -310,6 +284,13 @@
   
   	options = new EmbededServletOptions(config, context);
   
  +        // Get the classpath to use for compiling
  +        classpath = (String) context.getAttribute(Constants.SERVLET_CLASSPATH);
  +
  +        if (classpath == null || classpath.equals("")) {
  +            classpath = options.getClassPath();
  +        }
  +
   	// Get the parent class loader
   	parentClassLoader =
   	    (URLClassLoader) Thread.currentThread().getContextClassLoader();
  @@ -642,29 +623,6 @@
           }
   
   	return outDated;
  -    }
  -
  -
  -    /**
  -     * Determines whether the current JSP class is older than the JSP file
  -     * from whence it came
  -     * KMC: This is currently no used
  -     */
  -    public boolean isOutDated(File jsp, JspCompilationContext ctxt,
  -			      Mangler mangler ) {
  -        File jspReal = null;
  -	boolean outDated;
  -	
  -        jspReal = new File(ctxt.getRealPath(jsp.getPath()));
  -
  -        File classFile = new File(mangler.getClassFileName());
  -        if (classFile.exists()) {
  -            outDated = classFile.lastModified() < jspReal.lastModified();
  -        } else {
  -            outDated = true;
  -        }
  -
  -        return outDated;
       }
   
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message