| Author |
Redirect requests with web.xml url-pattern
|
Jeppe Sommer
Ranch Hand
Joined: Jan 07, 2004
Posts: 263
|
|
Hi.
I want to redirect all requests having a servletPath (request.getServletPath) through a servlet called RequestDispather.
I.e. I want this request to be redirected to RequestDispather:
http://127.0.0.1:8080/myApp/novo
http://127.0.0.1:8080/myApp/novo/
http://127.0.0.1:8080/myApp/novo/myfile.jsp
and not:
http://127.0.0.1:8080/myApp
http://127.0.0.1:8080/myApp/
http://127.0.0.1:8080/myApp/login.jsp
I am not sure how to define the url-pattern in web.xml:
N.B. I don't want to hardcode the folder "/novo/*" in servlet-mapping.
<servlet-mapping>
<servlet-name>RequestDispather</servlet-name>
<url-pattern>/*/*</url-pattern>
</servlet-mapping>
Any help would be appreciated.
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14491
|
|
There's no "servlet path" in a URL. The Servlet path is what gets extracted from the URL by as part of the process of routing a URL to a servlet.
In other words, URLs that retrieve images, JavaScript, CSS, and so forth, don't have "servlet paths". Actually, they do, but it's to the server's builtin default servlet, which doesn't count.
If you try and define a servlet path of something like "/*" in web.xml, however, that would cause all of the above resource requests to be re-routed to the associated servet, since a URL is a URL until it gets routed somewhere. And if it gets routed to your servlet, it won't be routed to the default servlet. Meaning that you'd break all handling of image, javascript and CSS requests.
|
Customer surveys are for companies who didn't pay proper attention to begin with.
|
 |
 |
|
|
subject: Redirect requests with web.xml url-pattern
|
|
|