You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2002/07/08 23:50:26 UTC

DO NOT REPLY [Bug 10568] New: - org.apache.jasper.servlet.JspServlet: bug creating output directory URL

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10568>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10568

org.apache.jasper.servlet.JspServlet: bug creating output directory URL

           Summary: org.apache.jasper.servlet.JspServlet: bug creating
                    output directory URL
           Product: Tomcat 4
           Version: Unknown
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Major
          Priority: Other
         Component: Jasper 2
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: daveho@cs.umd.edu


This bug is in org.apache.jasper.servlet.JspServlet revision 1.28 from CVS
(current as of July 8, 2002).  It's also in tomcat 4.0.3, which is what I'm running.

The loadJSP() method has the following code:

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

The problem is with the outputDir object, which is a java.io.File.  This object
does not know that it represents a directory, and if you convert it to a string,
it will not have a trailing separator character.  When a URL is created from
this file, it will not have a trailing separator character in its external form.

If you look at the documentation for URLClassLoader (which JasperLoader is a
subclass of), it says that 

"Any URL that ends with a '/' is assumed to refer to a directory.  Otherwise,
the URL is assumed to refer to a JAR file which will be downloaded and opened as
needed."

(This is a direct quote from the Sun JDK 1.4 API documentation.)

So, when outputDir is converted to a URL, it is reasonable to assume that it
will be treated as a jar file rather than a filesystem directory, which is
obviously not what is intended.

I assume that this bug has not manifested before because the Sun JDKs do not
appear to implement the behavior that is described in the API documentation;
presumably, if the base URL does not appear to be a jar file, the Sun
implementation will try to treat it as a directory.  However, from what I can
tell from reading the API documentation, this extra behavior is not required.

In case you're wondering why I'm reporting this as a bug, I'm using a virtual
machine which does not use the Sun libraries.  The JasperLoader fails to load a
compiled JSP because it thinks the directory it's in is a jar file.

To fix this problem, I think the use of the File object should be eliminated. 
It would be sufficient to create the URL as follows:

  urls[0] = new URL("file:" + normalize(ctxt.getOutputDir()));

This will preserve the trailing slash in the output directory path.

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>