On 06/03/2010 00:56, GreggCarrier wrote:
I'm having a frustrating problem and I can't find the right configuration for
what I want. Hoping someone can offer some insight.
Desired behavior: I want all requests to my webapp to be handled by one
servlet except requests for index.jsp or the root of the webapp. I do not
want trailing slashes to be required in order to load URLs.
The setups I have tried and the results:
1 -<servlet-mapping>
<servlet-name>Jersey Spring Web Application</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
In this case, the index.jsp loads fine at /mywebapp/. The servlet handles
all other requests appropriately EXCEPT it requires a trailing slash at the
end of all URLs. Eg, /mywebapp/foo/ loads but /mywebapp/foo does not. This
setup would be perfect except for the trailing slash requirement. I want it
to load with or without the trailing slash.
2 -<servlet-mapping>
<servlet-name>Jersey Spring Web Application</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
With this setup the servlet handles requests with and without the trailing
slash (correctly). The index.jsp will not load at /mywebapp/ or
/mywebapp/index.jsp.
Any ideas? Thanks very much!
Maybe one of the devs can confirm whether it's the DefaultServlet which
handles the redirect/forward/whatever from /dir to the trailing slash
variant /dir/? (I couldn't work it out from a quick look in SVN)
In 1) you are replacing the DefaultServlet, which may have other
consequences for your application.
In 2) the wildcard overrides the request for the welcome-file.
A Servlet Filter as previously suggested, would be my solution.
p
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]