On Oct 17, 2011, at 6:36 PM, Christopher Schultz wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Nathan,
On 10/17/2011 9:21 PM, Nathan Potter wrote:
No, but if you assign a servlet to "/" or "/*" it gets call
foreverything before anything starting with "*". Basically starts
with "/" trumps starts with "*" when applying url patterns.
If I'm reading that right (read it 5 or 6 times to just be sure I thin
I understand it), you are saying that:
a. Mapping Tomcat's DefaultServlet to "/" and
b. Mapping Tomcat's JSP Servlet to "*.jsp"
will result in DefaultServlet serving all content, and the JSP servlet
never running.
Almost. When I map our servlet to "/*". Then we see the problem.
Since that's the default configuration described above and JSPs and
static content certainly do work properly under the default
configuration, I must (still) be reading that incorrectly.
But this is the point. Look at the stack trace. The error is coming
from the Jasper JspServlet - my code is not being called. The
JspServlet is getting tapped to respond to the request URL
http://localhost:8080/contextName/admin
So there is no redirect going on? Obviously, redirects don't show in
stack traces...
I brought all the tomcat code into my IDE and set break points and all
that - my code is not accessed.
It looks like you haven't done that. But, if you haven't, then
why does the JSP servlet get invoked? You mapped it to
"/admin/*", not to "/admin"...
That's the question isn't it....
You didn't post the entire stack trace, so it's hard to tell.
I haven't been able to figure out how to get that to appear in the
Tomcat log. I use the logback log4j package and I have turned on
logging and added appenders fro org.apache and turned it up to all and
I haven't gotten any output...
Let's see the change you made. It might not work under all
circumstances.
Oh I'm sure it won't. It's a work around, not a patch by any
means. Here's the important part:
public class JspServlet extends
org.apache.jasper.servlet.JspServlet {
public void service(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException
{
String jspUri = request.getServletPath();
String pathInfo = request.getPathInfo(); if (pathInfo != null) {
jspUri += pathInfo; } String realPath =
context.getRealPath(jspUri);
File f = new File(realPath);
Oh, yeah, that definitely won't work: calling getRealPath isn't
reliable because you can't guarantee a "real" filesystem supporting
the webapp. It would be better to call ServletContext.getResource() or
something like that.
if(f.exists() && f.isDirectory()) {
Without a java.io.File, this is of course impossible.
Any fix should probably be applied in JspUtils.getInputStream. I'm not
a big fan of throwing FileNotFoundException for things that aren't
java.io.File objects (ignoring the Java API's behavior :) but I wonder
if a subclass of JasperException could be used in these situations.
In the case of the ZipEntry, you can ask a ZipEntry if it's a
directory: if so, maybe an even more explicit exception could be
thrown. When a ZipEntry isn't involved (e.g. serving directly off the
filesystem where the URI results in an attempt to get a stream for a
directory), it's less clear what to do other than throwing a
JasperFileNotFoundException or whatever.
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk6c2AAACgkQ9CaO5/Lv0PDdowCgiXGwX0c523f/jzgH7psJD761
Fb8An2V4nhD7xFbKfkdxl75jxTvtPrSn
=cLPU
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org
= = =
Nathan Potter ndp at opendap.org
OPeNDAP, Inc. +1.541.231.3317
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org