I'm not entirely sure how to make all requests to JSPs map directly to the HTML extension. For example, invoking index.jsp by only allowing the user to type index.html. If the user types "index.jsp" giving a 404 error instead.
You could create a servlet entry with mapping for each jsp page in your web.xml.
To keep them from typing '*.jsp' in directly, you could put your actual JSP pages under WEB-INF or use a filter that looks for '.jsp' at the end of the URI. You could also put them in a directory and create a mapping for that directory that sends them to your 404 page.
Thanks for your reply. I guess I'm trying to find a "silver bullet" since my web app creates JSP files dynamically. I suppose what I can do is get one of the servlets to add any new JSPs that have been created to the web.xml file (along with its url-mapping).
Based on Tim Baker's good idea, I came up with a Servlet that asks a Java class for a list (Vector) of names of HTML documents that are considered 'valid' (i.e. map 1:1 to JSP files). It then uses those names to map to the JSP (without the user knowing) and redirects to that JSP. If a user types in the name of an html document that does not exist (i.e. 404), I redirect to the 404 servlet. Since people here shared their time in answering, it's only fair I share the code (not that it's spectacular or anything):
The following entry must also be in the Web app's web.xml:
[ February 04, 2005: Message edited by: Arron Ferguson ] [ February 04, 2005: Message edited by: Arron Ferguson ]
Joined: Oct 04, 2003
Joined: Feb 01, 2005
the following line:
Should be replaced with:
Otherwise the user can type:
instead of index.html and it would still work.
I always seem to find these *after* I've submitted. :roll: