File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Filter not called Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Filter not called" Watch "Filter not called" New topic
Author

Filter not called

Jigs Mehta
Greenhorn

Joined: Apr 02, 2009
Posts: 6
I have a query as follows:

1. I call a jsp from my browser as "http://localhost:8080/myapp/test.jsp"
2. Now this page is a simple login form and accepts a username and password and then calls a servlet called "Authenticator".
3. this servlet basically checks the for username and password and forwards it to "/administrator/index.jsp".
4. I have a filter mapped to the URL "/administrator/index.jsp".
5. I want to know what should be the dispatcher tag contain if the servlet is forwarding the request using RequestDispatcher and secondly If the servlet is using response.sendRedirect() to forward to the index.jsp page.

Currently I am handling the forward by RequestDispatcher forward by making use of FORWARD value in the dispatcher element. My filter-mapping looks as follows:


Right now my filter is not being called when the servlet is foerwarding using response.sendRedirect("/administrator/index.jsp") due to the dispatcher element.
what should be the value included in the dispatcher element if I want the filter to be called for the response.sendRedirect() method?

I hope I am doing everything right.

Thanks in advance for all the help!!
Allen Bandela
Ranch Hand

Joined: Feb 16, 2006
Posts: 128

According to the servlet specification,

"New since version 2.4 of the Java Servlet specification is the ability to configure
filters to be invoked under request dispatcher forward() and include() calls."
Allen Bandela
Ranch Hand

Joined: Feb 16, 2006
Posts: 128

Remove the <dispatcher>FORWARD</dispatcher> element completely. This should work since a redirect basically is like a new request from the client.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Filter not called