How to identify which welcome file in servlet filter?

249 Views Asked by At

When a servlet filter is invoked corresponding to a request for a welcome-file, is there any way for the filter to get the name of the specific welcome-file that is being served up? getRequestURL stops at the context root (which is presumably because that is the url requested). I can map a filter to each of the possible welcome-files, but it would be more convenient to have them all go the same filter, and do something slightly different for each of them.

1

There are 1 best solutions below

1
On

Easy As I think is just take the URL in Session of Welcomefile.jsp and use in Filter.

In your case welcome file is not JSP , in Filter for .xhtml get HttpServletRequest.getRequestURL() instead of HttpServletRequest.getRequestURI()