Reputation: 605
I want to map a Servlet
to URLs ending in /
, like /user/register/
, /user/login/
, but not any other resource under that path, not /*
.
I tried /*/
, but it doesn't work.
Upvotes: 1
Views: 274
Reputation: 1108632
Map a Filter
on /*
and let it determine whether the request needs to be passed through the servlet or not.
if (request.getRequestURI().endsWith("/")) {
request.getRequestDispatcher("/servleturl").forward(request, response);
} else {
chain.doFilter(request, response);
}
This way you can just map the desired Servlet
on /servleturl
.
Upvotes: 1
Reputation: 10329
welcome-file-list is what you are looking for. under the welcome-file-list you can specify a list of welcome-files (each under its own welcome-file tag). When the request URL ends with /, the application would look for the presence of one of those files you have mentioned in welcome-file-list (in the order you have specified there i guess) under the folder pointed to by the URL, and serve that resource.
Upvotes: 0
Reputation: 15588
I may be wrong, but I'm not sure this is possible. the wildcard * is only used at the end of url patterns:
# this is a valid pattern to match anything after root:
*/
# this does not match anything because nothing can come after *
/*/
# this would match anything after the . that was htm
*.htm
Upvotes: 1