You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Dr. Evil" <dr...@sidereal.kz> on 2001/10/24 12:06:20 UTC

More experiments with changing the default (/) mapping

I have figured out a few things about how servlet-mapping and
RequestDispatcher might work together.

If I put in a servlet-mapping entry for /* (which will catch every
request coming in to the server, which is something which I need to
do), and I make the servlet which handles it look like this:

RequestDispatcher rd = context.getNamedDispatcher("default");
rd.forward(request, response);

then it works for serving plain old static files.  In toher words,
http://localhost/foo/bar.html will get the bar.html from the /foo
directory.

This leaves me with two problems:  First, if I understand correctly,
servlets are not allowed to modify the HttpRequest object.  This means
that my director servlet can't change which director bar.html will be
in.  This is bad for me.

Second, I can't get it to work at all for jsp pages.  I would have
thought that:

RequestDispatcher rd = context.getNamedDispatcher("jsp");
rd.forward(request, response);

would work but it doesn't.  I get an exception with a message
"org.apache.jasper.JasperException: No output directory: String index
out of range: -1".  I can't figure out why that is happening or what
to do about it.

So, any sugestions on a) changing the paths "default" and "jsp" will
use to get their source pages from and b) how to get jsp to work?

I also thought about doing this with filters, but the problem with
filters is that they can only dispatch to servlets, not to jsp or html
pages, which is what I need to do.  Any sugestions would be most
appreciated.

Thanks