| Author |
redirect in a filter class
|
reubin haz
Ranch Hand
Joined: May 12, 2005
Posts: 287
|
|
I have j2ee web app that uses filter to determine the timeout period. If the current time is longer than the last access time for a certain length. it will redirects to a logout page. But I got error: java.lang.IllegalStateException: Cannot forward after response has been committed. I know this error would occur if there is already some output of the page. But this is from a filter class. It's mapped to /* and is called before accessing any page. Why it's still complain this error?
Thanks.
|
SCJA, SCJP5.0, SCBCD, SCWCD
|
 |
Sebastian Janisch
Ranch Hand
Joined: Feb 23, 2009
Posts: 1183
|
|
When done correctly, it should not throw any exceptions.
Instead of calling doFilter() you send a redirect to break the chain.
Could you send some code?
|
JDBCSupport - An easy to use, light-weight JDBC framework -
|
 |
reubin haz
Ranch Hand
Joined: May 12, 2005
Posts: 287
|
|
|
I found that the error only occurs if I redirect it to an external website page. If I just redirect to another page within my web app, it's fine. But I need redirect it to an external webpage....
|
 |
reubin haz
Ranch Hand
Joined: May 12, 2005
Posts: 287
|
|
|
I found a solution. I use that redirected internal page to redirect again to the external webpage. Then it's working.
|
 |
 |
|
|
subject: redirect in a filter class
|
|
|