Hi, i want to map a servlet to URLs end with /. like /user/register/, /user/login/, but not any other resource under that path, not /*.
i tried /*/, but it doesn't work. so please help, is there anyway to make / like end extension mapping.
thanks.
Hi, i want to map a servlet to URLs end with /. like /user/register/, /user/login/, but not any other resource under that path, not /*.
i tried /*/, but it doesn't work. so please help, is there anyway to make / like end extension mapping.
thanks.
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
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.
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
.