Chuck,
I may not NEED to do it. It's just what I figured out to do.
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.
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.)
Attempting to change back to the Tomcat default servlet will cause a
change in the URL scheme of the web application, at least to the best
of my understanding (because our servlet would now be mapped to some /
name/* pattern). Our installed user base will not accept a new
version of product that requires all their URLs will to be different.
This is probably even true w.r.t. changing the context name, but
that's an installation decision not a mandate.
So all this brings me to say that the need is for my servlet to be the
default servlet and I need JSP to work.
What I thought to do was:
<servlet-mapping>
<servlet-name>hyrax</servlet-name>
<url-pattern>/*</url-pattern>
<url-pattern>/hyrax/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>/jsp/*</url-pattern>
<url-pattern>/admin/*</url-pattern>
<url-pattern>/error/*</url-pattern>
</servlet-mapping>
Which worked, but when accessing the URL:
http://localhost:8080/myContext/admin
I would get back a 500 error.
And:
http://localhost:8080/myContext/admin/
Would return the (index.jsp) welcome page.
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.
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.
N
On Oct 17, 2011, at 11:14 AM, Caldarale, Charles R wrote:
From: Nathan Potter [mailto:npot...@opendap.org]
Subject: JspServlet - Unexpected behavior, possible bug...
In my web application I need to utilize the JSP servlet, but
I need to use a different servlet mapping:
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>/jsp/*</url-pattern>
</servlet-mapping>
Before going any further, please explain why you think you need to
do that. (I.e., what's the actual requirement?)
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE
PROPRIETARY MATERIAL and is thus for use only by the intended
recipient. If you received this in error, please contact the sender
and delete the e-mail and its attachments from all computers.
---------------------------------------------------------------------
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