Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

endless loop with interceptor

 
Jordan Smith
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9527
32
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Jordan Smith
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you are right.

is there a way to apply a default interceptor to all the actions except for one?
 
Ankit Garg
Sheriff
Posts: 9527
32
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic