If any J2EE
application hit servlet directly and then servlet forward the same request to some .jsp
page.
request.getRequestDispatcher("Login.jsp").forward(request, response);
And I have a servlet filter with below url-pattern
<filter-mapping>
<filter-name>some_filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
So, will that forwarded request comes to filter also or not.
In my case it is not coming, is this a as expected behaviour. Just want to understand this.
If you want the filter mapping to be invoked for forward requests, you have to put this in web.xml
This support is there since Servlet2.4
The supported values for dispatcher are :
REQUEST: The request comes directly from the client. This is indicated by a
<dispatcher>
element with valueREQUEST
, or by the absence of any<dispatcher>
elements.FORWARD: The request is being processed under a request dispatcher representing the Web component matching the
<url-pattern>
or<servlet-name>
using aforward()
call. This is indicated by a<dispatcher>
element with valueFORWARD
.INCLUDE: The request is being processed under a request dispatcher representing the Web component matching the
<url-pattern>
or<servlet-name>
using aninclude()
call. This is indicated by a<dispatcher>
element with valueINCLUDE
.ERROR: The request that is being processed with the error page mechanism specified in ”Error Handling” to an error resource matching the
<url-pattern>
. This is indicated by a<dispatcher>
element with the valueERROR
.ASYNC: The request is being processed with the async context dispatch mechanism specified in ”Asynchronous processing” to a web component using a dispatch call. This is indicated by a
<dispatcher>
element with the valueASYNC
.