aspose file tools*
The moose likes Servlets and the fly likes Servlet Filter Issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet Filter Issue" Watch "Servlet Filter Issue" New topic
Author

Servlet Filter Issue

Naveen puttu
Ranch Hand

Joined: Sep 15, 2009
Posts: 88
Hi,

Below is a servlet filter code



I get IllegalStateException if try to redirect or use RequestDispatcher . It says "Cannot forward after response is committed"

Please help

Cheers
Naveen
Malatesh Karabisti
Ranch Hand

Joined: Jul 28, 2010
Posts: 153

Can you please post head of the error stack trace ?
Naveen puttu
Ranch Hand

Joined: Sep 15, 2009
Posts: 88
Here is the stack trace



By the way the control goes in this flow only at the moment



To add to the misery . The filter works perfectly fine once the server is restarted , but then throws this exception after a while (lets say when session times out )

I dont know whatz happening

Cheers
Naveen
Malatesh Karabisti
Ranch Hand

Joined: Jul 28, 2010
Posts: 153



have you tried by commenting the "return" in the block just try this
Naveen puttu
Ranch Hand

Joined: Sep 15, 2009
Posts: 88
Did that , still NO GO
parampreet sethi
Greenhorn

Joined: Aug 03, 2009
Posts: 27

You can try putting return after each forward and response.sendredirect method calls.

The forward and sendredirect method calls does not mean that the rest of the code will be ignored. Yesterday I was having the same issue and putting return after each sendRedirect and forward fixed this issue.

Hope it helps.


Param
Naveen puttu
Ranch Hand

Joined: Sep 15, 2009
Posts: 88
parampreet sethi wrote:You can try putting return after each forward and response.sendredirect method calls.

The forward and sendredirect method calls does not mean that the rest of the code will be ignored. Yesterday I was having the same issue and putting return after each sendRedirect and forward fixed this issue.

Hope it helps.


I tried that , as explained earlier . It works fine until the session times out . After that we are back to square one
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Servlet Filter Issue