Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Strauts Application configuring front controller action

 
Chhaya Patil
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In our application we are facing problem when user's session times out / user logs out and then try to access any random action. What i mean to say is, we have a start action which finds out user role and access level. but if the application is directly accessed without calling start action then we obviously get errors.

What is the way of forcefully calling the start action even though user accidently tried to access any other action.
(this may happen when someone bookmarks any action instead of actual application URL)

Thanks.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Save the requested action, redirect them to the login page, and send them back to the saved action.
 
Chhaya Patil
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The user is sent to log in page if sesion timed out. But what happens is directly the last action (action in URL) is accessed. Since i have lost valuable information from sesion, error occurs.

This can be avoided if whatever is URL, after logged in the Start action is called and Homepage is diaplyed, it's acceptable.

I can do a quick check in every action, if session variabes are null then to redirect to start but i am looking for a better solution.

Thanks.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your application requires recovering from a lost session at *any* point in workflow then you'd need to consider persisting session data in a database and restoring it on login.

Checking for a valid session data can be done in either an action superclass that all your other actions extend or in a custom request processor (S1.2) or whatever the equivalent is in S1.3.

If neither of those two options seems like what you're asking about then you'll have to be a bit more specific.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic