wood burning stoves 2.0*
The moose likes Struts and the fly likes endless loop with interceptor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "endless loop with interceptor" Watch "endless loop with interceptor" New topic
Author

endless loop with interceptor

Jordan Smith
Ranch Hand

Joined: Apr 06, 2008
Posts: 89
hi!

i have in my struts.xml the followings:


i wrote an interceptor, that i would like to be invoked after excecuting an action and before showing the results:


the interceptor codes needs to check that 20 minutes didn't pass since session started. (i didn't declared the session end time in web.xml since it comes from the database as a parameter).

However, when i run it - the browser gets into an endless loop.

Why is it?

thanks!
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

Okay I'm really not sure what you are trying to achieve with that code, but are you only trying to send the user to a different result page if the session has expired?? If so, why are you doing that after the action has executed?? Any user with no session should generally not even have access to the action. And if the actual goal is just to implement session timeout, you can set the session timeout of the session object from the value of the database in your action or a filter. The browser is going into a loop because session-timeout is a redirect result. So the browser will make a new request for that result, and then the interceptor will be fired again which will again redirect the browser. The solution is that you do not apply this interceptor to the getMainAction action...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Jordan Smith
Ranch Hand

Joined: Apr 06, 2008
Posts: 89
you are right.

is there a way to apply a default interceptor to all the actions except for one?
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

Just leave the default stack that you've created as it is and use a different interceptor stack for that particular action. Look at the configurations in this page to see how its done...
 
wood burning stoves
 
subject: endless loop with interceptor
 
Similar Threads
where to write the code for intercepts
ModelDriver Interceptor + not getting my object
Problem With Execute and Wait Interceptor
Struts 2 and Session Timeout
Struts 2 - passing request parameters to jsp from an Interceptor