tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kin...@apache.org
Subject cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet JspServlet.java
Date Wed, 24 Apr 2002 02:21:05 GMT
kinman      02/04/23 19:21:05

  Modified:    jasper2/src/share/org/apache/jasper CommandLineContext.java
                        JspCompilationContext.java JspEngineContext.java
                        Options.java
               jasper2/src/share/org/apache/jasper/compiler
                        CommandLineCompiler.java Compiler.java
                        JspCompiler.java TldLocationsCache.java
               jasper2/src/share/org/apache/jasper/servlet JspServlet.java
  Removed:     jasper2/src/share/org/apache/jasper JasperError.java
  Log:
  - Fixed 6907, to prevent jasper from simultaneous compilation of the same page,
    yet allows for simultaneous compilation of different pages.
  
  - Fixed 6909, to remove double file separator in file names.
  
  - Incorporate patch from jasper head branch to illegal class names used by
    Jspc.
  
  - Javadoc fixes.
  
  Revision  Changes    Path
  1.2       +24 -22    jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/CommandLineContext.java
  
  Index: CommandLineContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/CommandLineContext.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CommandLineContext.java	28 Mar 2002 18:46:15 -0000	1.1
  +++ CommandLineContext.java	24 Apr 2002 02:21:04 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/CommandLineContext.java,v
1.1 2002/03/28 18:46:15 kinman Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/03/28 18:46:15 $
  + * $Header: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/CommandLineContext.java,v
1.2 2002/04/24 02:21:04 kinman Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/24 02:21:04 $
    *
    * ====================================================================
    * 
  @@ -178,7 +178,8 @@
       }
       
       /**
  -     * What is the scratch directory we are generating code into?
  +     * The scratch directory to generate code into.
  +     *
        * FIXME: In some places this is called scratchDir and in some
        * other places it is called outputDir.
        */
  @@ -187,7 +188,8 @@
       }
       
       /**
  -     * What is the scratch directory we are generating code into?
  +     * The scratch directory to generate code into for javac.
  +     *
        * FIXME: In some places this is called scratchDir and in some
        * other places it is called outputDir.
        */
  @@ -213,33 +215,32 @@
       
       /**
        * The package name for the generated class.
  +     * The final package is assembled from the one specified in -p, and
  +     * the one derived from the path to jsp file.
        */
       public String getServletPackageName() {
  -        //get the path to the jsp file
  -        int indexOfSlash = getJspFile().lastIndexOf('/');
  +        //Get the path to the jsp file.  Note that the jspFile, by the
  +	//time it gets here, would have been normalized to use '/'
  +	//as file separator.
  +
  +	int indexOfSlash = getJspFile().lastIndexOf('/');
           String pathName;
           if (indexOfSlash != -1) {
               pathName = getJspFile().substring(0, indexOfSlash);
           } else {
               pathName = "/";
           }
  -        //Assemble the package name from the base package name speced on
  +
  +        //Assemble the package name from the base package name specified on
           //the command line and the package name derived from the path to
           //the jsp file
           String packageName = "";
  -        if (servletPackageName != null && !servletPackageName.equals("")) {
  +        if (servletPackageName != null) {
               packageName = servletPackageName;
           }
  -        if (packageName.equals("")) {
  -            packageName = pathName.replace('/', '.');
  -        } else {
  -            packageName += pathName.replace('/', '.');
  -        }
  -        //strip off any leading '.' in the package name
  -        if (!packageName.equals("") && packageName.charAt(0) == '.') {
  -            packageName = packageName.substring(1);
  -        }
  -        return packageName;
  +        packageName += pathName.replace('/', '.');
  +
  +        return CommandLineCompiler.manglePackage(packageName);
       }
   
       /**
  @@ -258,8 +259,9 @@
       }
   
       /**
  -     * What's the content type of this JSP? Content type includes
  -     * content type and encoding. 
  +     * The content type of this JSP.
  +     *
  +     * Content type includes content type and encoding. 
        */
       public String getContentType() {
           return contentType;
  @@ -340,7 +342,7 @@
       /**
        * Gets a resource as a stream, relative to the meanings of this
        * context's implementation.
  -     *@returns a null if the resource cannot be found or represented 
  +     * @return a null if the resource cannot be found or represented 
        *         as an InputStream.
        */
       public java.io.InputStream getResourceAsStream(String res) {
  
  
  
  1.2       +15 -9     jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspCompilationContext.java
  
  Index: JspCompilationContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspCompilationContext.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JspCompilationContext.java	28 Mar 2002 18:46:15 -0000	1.1
  +++ JspCompilationContext.java	24 Apr 2002 02:21:05 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspCompilationContext.java,v
1.1 2002/03/28 18:46:15 kinman Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/03/28 18:46:15 $
  + * $Header: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspCompilationContext.java,v
1.2 2002/04/24 02:21:05 kinman Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/24 02:21:05 $
    *
    * ====================================================================
    * 
  @@ -111,14 +111,16 @@
       public boolean isErrorPage();
       
       /**
  -     * What is the scratch directory we are generating code into?
  +     * The scratch directory to generate code into.
  +     *
        * FIXME: In some places this is called scratchDir and in some
        * other places it is called outputDir.
        */
       public String getOutputDir();
       
       /**
  -     * What is the scratch directory we are generating code into?
  +     * The scratch directory to generate code into for javac.
  +     *
        * FIXME: In some places this is called scratchDir and in some
        * other places it is called outputDir.
        */
  @@ -153,8 +155,9 @@
       public boolean keepGenerated();
   
       /**
  -     * What's the content type of this JSP? Content type includes
  -     * content type and encoding. 
  +     * The content type of this JSP.
  +     *
  +     * Content type includes content type and encoding. 
        */
       public String getContentType();
   
  @@ -193,7 +196,7 @@
       /**
        * Gets a resource as a stream, relative to the meanings of this
        * context's implementation.
  -     *@returns a null if the resource cannot be found or represented 
  +     * @return a null if the resource cannot be found or represented 
        *         as an InputStream.
        */
       public java.io.InputStream getResourceAsStream(String res);
  @@ -206,11 +209,14 @@
        */
       public String getRealPath(String path);
   
  +    static interface Interface1 {
  +    }
  +
       /**
        * Get the 'location' of the TLD associated with 
        * a given taglib 'uri'.
        * 
  -     * @returns An array of two Strings. The first one is
  +     * @return An array of two Strings. The first one is
        * real path to the TLD. If the path to the TLD points
        * to a jar file, then the second string is the
        * name of the entry for the TLD in the jar file.
  
  
  
  1.3       +12 -11    jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspEngineContext.java
  
  Index: JspEngineContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspEngineContext.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JspEngineContext.java	30 Mar 2002 09:36:29 -0000	1.2
  +++ JspEngineContext.java	24 Apr 2002 02:21:05 -0000	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspEngineContext.java,v
1.2 2002/03/30 09:36:29 remm Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/03/30 09:36:29 $
  + * $Header: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspEngineContext.java,v
1.3 2002/04/24 02:21:05 kinman Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/04/24 02:21:05 $
    *
    * ====================================================================
    * 
  @@ -186,16 +186,15 @@
       }
       
       /**
  -     * What class loader to use for loading classes while compiling
  -     * this JSP? I don't think this is used right now -- akv. 
  +     * The class loader to use for loading classes while compiling
  +     * this JSP.
        */
       public ClassLoader getClassLoader() {
           return Thread.currentThread().getContextClassLoader();
       }
   
       /**
  -     * Are we processing something that has been declared as an
  -     * errorpage? 
  +     * Return true if the current page is an errorpage.
        */
       public boolean isErrorPage() {
           return isErrPage;
  @@ -211,7 +210,8 @@
       }
       
       /**
  -     * What is the scratch directory we are generating code into?
  +     * Get the scratch directory to place generated code for javac.
  +     *
        * FIXME: In some places this is called scratchDir and in some
        * other places it is called outputDir.
        */
  @@ -258,8 +258,9 @@
       }
   
       /**
  -     * What's the content type of this JSP? Content type includes
  -     * content type and encoding. 
  +     * Get the content type of this JSP.
  +     *
  +     * Content type includes content type and encoding.
        */
       public String getContentType() {
           return contentType;
  @@ -357,7 +358,7 @@
       /**
        * Gets a resource as a stream, relative to the meanings of this
        * context's implementation.
  -     *@returns a null if the resource cannot be found or represented 
  +     * @return a null if the resource cannot be found or represented 
        *         as an InputStream.
        */
       public java.io.InputStream getResourceAsStream(String res)
  
  
  
  1.2       +3 -3      jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/Options.java
  
  Index: Options.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/Options.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Options.java	28 Mar 2002 18:46:15 -0000	1.1
  +++ Options.java	24 Apr 2002 02:21:05 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/Options.java,v
1.1 2002/03/28 18:46:15 kinman Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/03/28 18:46:15 $
  + * $Header: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/Options.java,v
1.2 2002/04/24 02:21:05 kinman Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/24 02:21:05 $
    *
    * ====================================================================
    * 
  @@ -137,7 +137,7 @@
        * web.xml or implicitely via the uri tag in the TLD 
        * of a taglib deployed in a jar file (WEB-INF/lib).
        *
  -     * @returns the instance of the TldLocationsCache
  +     * @return the instance of the TldLocationsCache
        * for the web-application.
        */
       public TldLocationsCache getTldLocationsCache();
  
  
  
  1.3       +45 -18    jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/CommandLineCompiler.java
  
  Index: CommandLineCompiler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/CommandLineCompiler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CommandLineCompiler.java	4 Apr 2002 02:34:01 -0000	1.2
  +++ CommandLineCompiler.java	24 Apr 2002 02:21:05 -0000	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/CommandLineCompiler.java,v
1.2 2002/04/04 02:34:01 kinman Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/04/04 02:34:01 $
  + * $Header: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/CommandLineCompiler.java,v
1.3 2002/04/24 02:21:05 kinman Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/04/24 02:21:05 $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -61,6 +61,7 @@
   
   import java.io.File;
   import java.io.IOException;
  +import java.util.StringTokenizer;
   
   import org.apache.jasper.Constants;
   import org.apache.jasper.JspCompilationContext;
  @@ -86,8 +87,6 @@
           jsp = new File(ctxt.getJspFile());
           outputDir =  ctxt.getOptions().getScratchDir().getAbsolutePath();
   	packageName = ctxt.getServletPackageName();
  -	if( packageName == null )
  -	    packageName = "";
   	pkgName = packageName;
           setMangler(this);
   
  @@ -113,7 +112,7 @@
   
       /**
        * Always outDated.  (Of course we are, this is an explicit invocation
  -     *@returns true
  +     * @return true
        */
       public boolean isOutDated() {
           return true;
  @@ -163,33 +162,39 @@
                   className = jsp.getName().substring(0, jsp.getName().length() - 4);
               else
                   className = jsp.getName();
  +
           }
  +	return mangleName(className);
  +    }
   	
  +    private static final String mangleName(String name) {
  +
   	// since we don't mangle extensions like the servlet does,
   	// we need to check for keywords as class names
   	for (int i = 0; i < keywords.length; i++) {
  -	    if (className.equals(keywords[i])) {
  -		className += "%";
  +	    if (name.equals(keywords[i])) {
  +		name += "%";
  +		break;
   	    };
   	};
   	
   	// Fix for invalid characters. If you think of more add to the list.
  -	StringBuffer modifiedClassName = new StringBuffer();
  -	if (Character.isJavaIdentifierStart(className.charAt(0)))
  -	    modifiedClassName.append(className.charAt(0));
  +	StringBuffer modifiedName = new StringBuffer();
  +	if (Character.isJavaIdentifierStart(name.charAt(0)))
  +	    modifiedName.append(name.charAt(0));
   	else
  -	    modifiedClassName.append(mangleChar(className.charAt(0)));
  -	for (int i = 1; i < className.length(); i++) {
  -	    if (Character.isJavaIdentifierPart(className.charAt(i)))
  -		modifiedClassName.append(className.charAt(i));
  +	    modifiedName.append(mangleChar(name.charAt(0)));
  +	for (int i = 1; i < name.length(); i++) {
  +	    if (Character.isJavaIdentifierPart(name.charAt(i)))
  +		modifiedName.append(name.charAt(i));
   	    else
  -		modifiedClassName.append(mangleChar(className.charAt(i)));
  +		modifiedName.append(mangleChar(name.charAt(i)));
   	}
   	
  -	return modifiedClassName.toString();
  +	return modifiedName.toString();
       }
   
  -    public static final String mangleChar(char ch) {
  +    private static final String mangleChar(char ch) {
   	
           if(ch == File.separatorChar) {
   	    ch = '/';
  @@ -205,6 +210,28 @@
   	return new String(result);
       }
   
  +    /**
  +     * Make sure that the package name is a legal Java name
  +     *
  +     * @param name The input string, containing arbitary chars separated by
  +     *             '.'s, with possible leading, trailing, or double '.'s
  +     * @return legal Java package name.
  +     */
  +    public static String manglePackage(String name) {
  +        boolean first = true;
  +
  +        StringBuffer b = new StringBuffer();
  +        StringTokenizer t = new StringTokenizer(name, ".");
  +        while (t.hasMoreTokens()) {
  +            String nt = t.nextToken();
  +            if (nt.length() > 0) {
  +                if (b.length() > 0)
  +                    b.append('.');
  +                b.append(mangleName(nt));
  +            }
  +        }
  +        return b.toString();
  +    }
   
       public final String getClassName() {
           return className;
  
  
  
  1.3       +6 -19     jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Compiler.java
  
  Index: Compiler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Compiler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Compiler.java	30 Mar 2002 09:36:30 -0000	1.2
  +++ Compiler.java	24 Apr 2002 02:21:05 -0000	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Compiler.java,v
1.2 2002/03/30 09:36:30 remm Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/03/30 09:36:30 $
  + * $Header: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Compiler.java,v
1.3 2002/04/24 02:21:05 kinman Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/04/24 02:21:05 $
    *
    * ====================================================================
    * 
  @@ -67,7 +67,6 @@
   import org.apache.jasper.JspCompilationContext;
   import org.apache.jasper.Constants;
   import org.apache.jasper.JasperException;
  -import org.apache.jasper.JasperError;
   import org.apache.jasper.logging.Logger;
   
   /**
  @@ -99,21 +98,10 @@
       
       /** 
        * Compile the jsp file from the current engine context
  -     *
  -     * @return true if the class file was outdated the jsp file
  -     *         was recompiled. 
        */
  -    public boolean compile()
  +    public void compile()
   	    throws FileNotFoundException, JasperException, Exception {
   
  -        String classFileName = mangler.getClassFileName();
  -
  -        String className = mangler.getClassName();
  -        ctxt.setServletClassName(className);
  -
  -	if (!isOutDated())
  -            return false;
  -
   	// Setup page info area
   	pageInfo = new PageInfo(new BeanRepository(ctxt.getClassLoader()));
   
  @@ -192,6 +180,7 @@
               b.append(" ");
           }
   
  +
           Constants.message("jsp.message.compiling_with",
                             new Object[] { b.toString() },
                             Logger.DEBUG);
  @@ -204,7 +193,7 @@
   
           // if no compiler was set we can kick out now
           if (javac == null) {
  -            return true;
  +            return;
           }
   
           /*
  @@ -230,8 +219,6 @@
           if (!success) {
               errDispatcher.javacError(out.toString(), javaFileName, pageNodes);
           }
  -
  -        return true;
       }
   
       /**
  
  
  
  1.3       +7 -18     jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspCompiler.java
  
  Index: JspCompiler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspCompiler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JspCompiler.java	30 Mar 2002 09:36:30 -0000	1.2
  +++ JspCompiler.java	24 Apr 2002 02:21:05 -0000	1.3
  @@ -85,11 +85,6 @@
       String jsp;
       String outputDir;
   
  -    //    ClassFileData cfd;
  -    boolean outDated;
  -
  -    long lastChecked = -1;
  -
       Logger.Helper loghelper = new Logger.Helper("JASPER_LOG", "JspCompiler");
       
       public JspCompiler(JspCompilationContext ctxt) throws JasperException {
  @@ -97,13 +92,14 @@
           
           this.jsp = ctxt.getJspFile();
           this.outputDir = ctxt.getOutputDir();
  -        this.outDated = false;
           setMangler(this);
       }
   
       public final String getClassName() {
  -	if( realClassName == null )
  +	if( realClassName == null ) {
   	    realClassName = getBaseClassName();
  +	    ctxt.setServletClassName(realClassName);
  +	}
           return realClassName;
       }
   
  @@ -111,7 +107,7 @@
           if( javaFileName!=null ) return javaFileName;
   	javaFileName = getClassName() + ".java";
    	if (outputDir != null && !outputDir.equals(""))
  - 	    javaFileName = outputDir + File.separatorChar + javaFileName;
  +	    javaFileName = outputDir + javaFileName;
   	return javaFileName;
       }
       
  @@ -177,10 +173,6 @@
       public boolean isOutDated() {
   
           long time = System.currentTimeMillis();
  -        if (time < lastChecked)
  -            return false;
  -
  -        lastChecked = time + 2000;
   
           long jspRealLastModified = 0;
   
  @@ -195,13 +187,10 @@
           }
   
           File classFile = new File(getClassFileName());
  -        if (classFile.exists()) {
  -            outDated = classFile.lastModified() < jspRealLastModified;
  -        } else {
  -            outDated = true;
  -        }
  +        if (classFile.exists())
  +            return classFile.lastModified() < jspRealLastModified;
   
  -        return outDated;
  +        return true;
   
       }
   }
  
  
  
  1.2       +1 -1      jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TldLocationsCache.java
  
  Index: TldLocationsCache.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TldLocationsCache.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TldLocationsCache.java	28 Mar 2002 18:46:17 -0000	1.1
  +++ TldLocationsCache.java	24 Apr 2002 02:21:05 -0000	1.2
  @@ -290,7 +290,7 @@
        * Get the 'location' of the TLD associated with 
        * a given taglib 'uri'.
        * 
  -     * @returns An array of two Strings. The first one is
  +     * @return An array of two Strings. The first one is
        * real path to the TLD. If the path to the TLD points
        * to a jar file, then the second string is the
        * name of the entry for the TLD in the jar file.
  
  
  
  1.3       +34 -32    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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JspServlet.java	30 Mar 2002 09:36:30 -0000	1.2
  +++ JspServlet.java	24 Apr 2002 02:21:05 -0000	1.3
  @@ -83,7 +83,6 @@
   import java.security.Policy;
   import java.security.PrivilegedAction;
   
  -import org.apache.jasper.JasperError;
   import org.apache.jasper.JasperException;
   import org.apache.jasper.Constants;
   import org.apache.jasper.Options;
  @@ -101,7 +100,7 @@
   import org.apache.jasper.logging.JasperLogger;
   
   /**
  - * The JSP engine (a.k.a Jasper)! 
  + * The JSP engine (a.k.a Jasper).
    *
    * The servlet container is responsible for providing a
    * URLClassLoader for the web application context Jasper
  @@ -113,6 +112,7 @@
    * @author Anil K. Vijendran
    * @author Harish Prabandham
    * @author Remy Maucherat
  + * @author Kin-man Chung
    */
   public class JspServlet extends HttpServlet {
   
  @@ -396,10 +396,13 @@
   
   	boolean isErrorPage = exception != null;
   	
  -	JspServletWrapper wrapper = (JspServletWrapper) jsps.get(jspUri);
  -	if (wrapper == null) {
  -	    wrapper = new JspServletWrapper(jspUri, isErrorPage);
  -	    jsps.put(jspUri, wrapper);
  +	JspServletWrapper wrapper;
  +	synchronized (this) {
  +	    wrapper = (JspServletWrapper) jsps.get(jspUri);
  +	    if (wrapper == null) {
  +		wrapper = new JspServletWrapper(jspUri, isErrorPage);
  +		jsps.put(jspUri, wrapper);
  +	    }
   	}
   	
   	wrapper.service(request, response, precompile);
  @@ -497,9 +500,6 @@
               serviceJspFile(request, response, jspUri, null, precompile);
   	} catch (RuntimeException e) {
   	    throw e;
  -        } catch (JasperError ex) {
  -            response.setContentType("text/html");
  -            response.getWriter().print(ex.getMessage());
   	} catch (ServletException e) {
   	    throw e;
   	} catch (IOException e) {
  @@ -567,19 +567,16 @@
                    req, res);
           }
           JspCompilationContext ctxt = jsw.ctxt;
  -	boolean outDated = false; 
  -
  +	boolean outDated; 
           Compiler compiler = ctxt.createCompiler();
           
           try {
  -            outDated = compiler.compile();
  -            if ( (jsw.servletClass == null) || (compiler.isOutDated()) ) {
  -                synchronized ( this ) {
  -                    if ((jsw.servletClass == null) ||
  -			(compiler.isOutDated() ))  {
  -                        outDated = compiler.compile();
  -                    }
  -		}
  +	    synchronized(jsw) {
  +		// Synchronizing on jsw enables simultaneous compilations of
  +		// different pages, but not the same page.
  +		outDated = compiler.isOutDated();
  +		if (outDated)
  +		    compiler.compile();
               }
           } catch (FileNotFoundException ex) {
               compiler.removeGeneratedFiles();
  @@ -591,18 +588,24 @@
                                         ex);
   	}
   
  -	// Reload only if it's outdated
  -	if((jsw.servletClass == null) || outDated) {
  +        // Reload only if it's outdated
  +	if ((jsw.servletClass == null) || outDated) {
   	    try {
  -		URL [] urls = new URL[1];
  -                File outputDir = new File(normalize(ctxt.getOutputDir()));
  -                urls[0] = outputDir.toURL();
  -                jsw.loader = new JasperLoader(urls,ctxt.getServletClassName(),
  -					      parentClassLoader,
  -					      permissionCollection,
  -					      codeSource);
  -		jsw.servletClass = jsw.loader.loadClass(
  -			Constants.JSP_PACKAGE_NAME + "." + ctxt.getServletClassName());
  +		synchronized (jsw) {
  +		    if (jsw.servletClass == null) {
  +			URL [] urls = new URL[1];
  +			File outputDir = new File(normalize(ctxt.getOutputDir()));
  +			urls[0] = outputDir.toURL();
  +			jsw.loader = new JasperLoader(
  +						urls,ctxt.getServletClassName(),
  +						parentClassLoader,
  +						permissionCollection,
  +						codeSource);
  +			jsw.servletClass = jsw.loader.loadClass(
  +				Constants.JSP_PACKAGE_NAME + "." +
  +				ctxt.getServletClassName());
  +		    }
  +		}
   	    } catch (ClassNotFoundException cex) {
   		throw new JasperException(
   		    Constants.getString("jsp.error.unable.load"),cex);
  @@ -620,6 +623,7 @@
       /**
        * 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 ) {
  @@ -695,6 +699,4 @@
   	return (normalized);
   
       }
  -
  -
   }
  
  
  

--
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