java.lang.Object
com.aoapps.servlet.filter.HideJspExtensionFilter
- All Implemented Interfaces:
Filter
A servlet filter that hides the .jspx or .jsp extension from JSP-based sites.
It accomplishes this with the following steps:
- Rewrite any URLs ending in "/path/index.jsp(x)" to "/path/", maintaining any query string
- Rewrite any URLs ending in "/path/file.jsp(x)" to "/path/file", maintaining any query string
- 301 redirect any incoming GET request ending in "/path/index.jsp(x)" to "/path/" (to not lose traffic after enabling the filter)
- 301 redirect any incoming GET request ending in "/path/file.jsp(x)" to "/path/file" (to not lose traffic after enabling the filter)
- Forward incoming request of "/path/" to "/path/index.jsp(x)", if the resource exists. This is done by container with a welcome file list of index.jsp(x) in web.xml.
- Forward incoming request of "/path/file" to "/path/file.jsp(x)", if the resource exists
- Send any other request down the filter chain
When both *.jspx and *.jsp resources exist, the *.jspx is used.
This should be used for the DispatcherType.REQUEST and DispatcherType.ERROR dispatchers.
In the filter chain, it is important to consider the forwarding performed by this filter. Subsequent filters
may need DispatcherType.FORWARD dispatcher in addition to DispatcherType.REQUEST to see the forwarded requests.
Note: When testing in Tomcat 7, /WEB-INF/ protection was not compromised by the forwarding. Requests to /WEB-INF/ never even hit the filter.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()voiddoFilter(ServletRequest request, ServletResponse response, FilterChain chain) voidinit(FilterConfig config)
-
Constructor Details
-
HideJspExtensionFilter
public HideJspExtensionFilter()
-
-
Method Details
-
init
-
doFilter
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException - Specified by:
doFilterin interfaceFilter- Throws:
IOExceptionServletException
-
destroy
public void destroy()
-
