-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Nathan,
On 10/17/2011 12:47 PM, Nathan Potter wrote: > - BUT, If I request a URL (without a trailing slash) that > references an existing directory within the the JSP servlet's > purview, I get an HTTP status 500 (Internal Server Error). > http://localhost:8080/test/jsp/foo > > I think this is incorrect behavior. > > When I do the same experiment with the default servlet I get an > empty directory, but no error. > > I looked at the Tomcat code referenced by the stack trace: > org.apache.jasper.JasperException: File "/jsp/foo" not found > org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51) > > > org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409) > > > org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:116) > > > org.apache.jasper.compiler.JspUtil.getInputStream(JspUtil.java:851) > > org.apache.jasper.xmlparser.XMLEncodingDetector.getEncoding(XMLEncodingDetector.java:108) > > org.apache.jasper.compiler.ParserController.determineSyntaxAndEncoding(ParserController.java:348) > > > org.apache.jasper.compiler.ParserController.doParse(ParserController.java:207) > > > org.apache.jasper.compiler.ParserController.parseDirectives(ParserController.java:120) > > > org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:180) > > org.apache.jasper.compiler.Compiler.compile(Compiler.java:354) > org.apache.jasper.compiler.Compiler.compile(Compiler.java:334) > org.apache.jasper.compiler.Compiler.compile(Compiler.java:321) > org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592) > > > org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328) > > > org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313) > > org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) > javax.servlet.http.HttpServlet.service(HttpServlet.java:717) > > And I can see that in JspServlet in lines 312 - 316: > > try { wrapper.service(request, response, precompile); } catch > (FileNotFoundException fnfe) { handleMissingResource(request, > response, jspUri); } > > The call is being serviced. Unfortunately when this problem occurs > a "JasperException" is throw, not a FileNotFoundException and the > handleMissingResource() path way is skipped.... > > Any thoughts? It strikes me that this situation is one that can > easily be incurred by a type in the URL and so I don't that that an > HTTP staus of 500 should be returned in this situation. I'd be interested to see what else happened. It looks like JspServlet is trying to compile the directory. The "file" (the directory) *does* exist, so you don't get a FileNotFoundException. This seems like an edge case that the JspServlet wasn't designed to handle. So, I'd bet that this is a bug, but nobody cares but you. :) What version are you using? The numbers don't match 7.0.x trunk, but I was able to trace-through the call stack to here in JspUtils.java: public static InputStream getInputStream(String fname, JarFile jarFile, JspCompilationContext ctxt, ErrorDispatcher err) throws JasperException, IOException { inputStream in = null; if (jarFile != null) { String jarEntryName = fname.substring(1, fname.length()); ZipEntry jarEntry = jarFile.getEntry(jarEntryName); if (jarEntry == null) { err.jspError("jsp.error.file.not.found", fname); } in = jarFile.getInputStream(jarEntry); } else { in = ctxt.getResourceAsStream(fname); } if (in == null) { err.jspError("jsp.error.file.not.found", fname); } return in; } Looks like the null-checks here cause the problem you're seeing. Either the JAR file containing the resource can't find a ZipEntry or the ServletContext can't load a resource from the (disk, WAR, etc.). ZipEntry returns null when asked for an input stream (that is, no exception is thrown) for a directory, as does ServletContext. - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk6ciukACgkQ9CaO5/Lv0PCa2ACbBJIyTIt0hscpDhIRwaUI5MGl S+4AnA9uGxXHJlP0bnxUASZLoWiZyHzy =klJI -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org