I would like to have a Servlet handle all requests to JSP pages first. The Servlet will be used to set server side variables depending on the requested JSP.
For example, what I would like to achieve is given the url:example.com/index.jsp, the Servlet first handles the request by parsing out the requested JSP (index.jsp), sets variables that are specific to the requested index.jsp (using request.setAttribute) and then dispatches to the actual index.jsp (eg. /WEB-INF/index.jsp). The JSP will then have the correct variables it needs.
My problem so far is that I'm using "/*" as the mapping pattern for my Servlet. It handles the request, then uses requestDispatcher.forward("/WEB-INF/index.jsp") which ends up in an infinite loop since this matches the "/*" pattern as well.
How should my Servlet(s) handle the requested url? What should the I use as the mapping pattern(s) in web.xml?
Is there a standard setup for this? I'm just looking for a "best practices" way to set up pre-processing for all my JSPs.
 
     
    