-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Nathan,

On 10/17/2011 4:50 PM, Nathan Potter wrote:
> Historically, the servlet that I am working with has been the
> default servlet. Tomcat's default servlet was used to serve docs
> from a subdirectory of the context dir, and everything else was
> dynamically generated by the default servlet. JSP was never used so
> no there was no issue there.

I'm guessing that "the default servlet" really has at least two
meanings above.. it's not at all clear what you're talking about.

> A new feature has been added to the web application that requires
> JSP. But because an alternative default servlet is defined, this
> disables the use of the JspServlet using the *.jsp url-pattern in
> the servlet mapping. (This may be caused by a failure to properly
> implement the alternate default servlet?? I don't know how to
> tell.)

Wait, what? Changing the default servlet un-maps the JSP servlet?
Something must be wrong with your configuration.

> What I thought to do was:
> 
> <servlet-mapping> <servlet-name>hyrax</servlet-name> 
> <url-pattern>/*</url-pattern> <url-pattern>/hyrax/*</url-pattern> 
> </servlet-mapping>

FYI those two mappings are redundant: /* includes /hyrax/*. A "*"
doesn't mean "anything but a /", it indicates that anything that
starts with "/hyrax/" should be mapped to the "hyrax" servlet. URL
mappings in web.xml aren't as expressive as just about anyone would
like them to be. Specifically, they are neither simple globs nor are
they regular expressions.

> <servlet-mapping> <servlet-name>jsp</servlet-name> 
> <url-pattern>/jsp/*</url-pattern> 
> <url-pattern>/admin/*</url-pattern> 
> <url-pattern>/error/*</url-pattern> </servlet-mapping>

What's wrong with the default, which is "/*.jsp" for the JSP servlet?
Do you have files with the .jsp extension that you need served without
actually invoking the JSP servlet?

> Which worked, but when accessing the URL:
> 
> http://localhost:8080/myContext/admin
> 
> I would get back a 500 error.

So don't do that :)

> And:
> 
> http://localhost:8080/myContext/admin/
> 
> Would return the (index.jsp) welcome page.

I would have expected an error, same as above.

> Now, one might argue that the first URL should 404, or one might
> argue that it should redirect to the 2nd URL. But I think it's a
> tough argument to make that it should return a 500 error.

If you implemented your default servlet in the same way that Tomcat's
is done, then a redirect from /admin -> /admin/ will occur. 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"...

> And I didn't see anywhere in the documentation that said you
> SHOULDN'T use the JSP Servlet this way...
> 
> I wrote a work around by subclassing 
> org.apache.jasper.servlet.JspServlet and wrapping/overriding the 
> service() method with a check for the directory w/o the trailing
> slash condition and returning a redirect when it happens and
> passing the call down to super.service() when it doesn't. That
> works great, but I figured the 500 error wasn't a desired behavior
> so I wrote in to the list about it, as the documentation at Tomcat
> home indicated that all bug reports should begin here.

Let's see the change you made. It might not work under all circumstances.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk6cz5AACgkQ9CaO5/Lv0PAs0ACfUhNocwUmqavtJ8ilBn5QZPBT
kscAnjRDeapkGccOE4MvsWVqoteuN7wK
=IgYU
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to