I\'m trying to follow the pattern at Design Patterns web based applications. It all works fine part from when it comes to maping \"root\" URLs.
I\'d like to put all
The /* URL pattern covers everything, also the forwarded JSP files and static resources like CSS/JS/images. You don't want to have that on a front controller servlet.
Keep your controller servlet on a more specific URL pattern like /pages/*. You can achieve the functional requirement of getting rid of "/pages" in the URL by grouping the static resources in a common folder like /resources and creating a Filter which is mapped on /* and does the following job in the doFilter() method:
HttpServletRequest req = (HttpServletRequest) request;
String path = req.getRequestURI().substring(req.getContextPath().length());
if (path.startsWith("/resources/")) {
// Just let container's default servlet do its job.
chain.doFilter(request, response);
} else {
// Delegate to your front controller.
request.getRequestDispatcher("/pages" + path).forward(request, response);
}
A forwarded JSP resource will by default not match this filter, so it will properly be picked up by the container's own JspServlet.