It's not a secret anymore!*
The moose likes Servlets and the fly likes Redirect user to current page after session expire when the user resumes 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 » Java » Servlets
Bookmark "Redirect user to current page after session expire when the user resumes" Watch "Redirect user to current page after session expire when the user resumes" New topic
Author

Redirect user to current page after session expire when the user resumes

rajeev yadav
Greenhorn

Joined: Mar 28, 2011
Posts: 26
Hi All,

I have below requirement:
1. Expire user session after 15 min
2. When user resumes, a new session should be created and for end user application should work like session was never expire. Means, he should be allowed to resume to work from same state where he was in application without any errors.

For 1st thing, I have set session timeout in web.xml. For second part, I would like to know this can be handled. Any pointers are highly appreciated.

Thanks,
Rajeev
Vijay Tidake
Ranch Hand

Joined: Nov 04, 2008
Posts: 146

Hi,

Can you elaborate this statement

When user resumes, a new session should be created and for end user application should work like session was never expire.


I am not getting for whom session should expire and for whom not?

Thanks


The important thing is not to stop questioning.Curiosity has its own reason for existing.
Ashwin Sridhar
Ranch Hand

Joined: Jul 09, 2011
Posts: 272

By resuming the session, you want to authenticate the user again and create the session. If this is the case, how do you think, the user shouldn't know that another session is being created.
Another question, you invalidate the session after 15mins, when you invalidate, the attributes associated with the session will be lost, how do you plan to retain them


Ashwin Sridhar
SCJP | SCWCD | OCA
Sridhar Santhanakrishnan
Ranch Hand

Joined: Mar 20, 2007
Posts: 317
I think what the OP means is that once the user logs in again, he should be redirected to the page last being viewed before the session expiry and not the default landing page.

For ex: on JavaRanch, say you are viewing a post and decide to reply. You log in, and once authenticated, JR redirects you to the post that you viewed before.
rajeev yadav
Greenhorn

Joined: Mar 28, 2011
Posts: 26
Sridhar is right... This is exactly my requirement..
Vijay Tidake
Ranch Hand

Joined: Nov 04, 2008
Posts: 146

Hi,

Then you may go for the spring user security.It will provide you a lot more functionalities along with this one.

Thanks
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12759
    
    5
You can certainly use a cookie to record the identity of the "current" page every time you send a response, if that is what you are asking.

Bill
rajeev yadav
Greenhorn

Joined: Mar 28, 2011
Posts: 26
Hi Bill,

Cookie has many restrictions and also depends on client side settings. So does not seem to be resolving the issue.

About Spring security integration with wicket, I would like to know how it can be done and also if I can get any helpful documentation on integration.

Thanks,
Rajeev
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

If the user is logging in from a page which needs to be displayed again then the referrer URL can be used to send him back to the same page.


SCJP, SCWCD.
|Asking Good Questions|
Sujata Samal
Greenhorn

Joined: Jan 29, 2008
Posts: 20
A simplest way could be have a comon method lets say isSessionValid() and every action you perform call this method.

inside isSessionValid() verify if the session is invalid/expired then foreward to the login page with the current url as a request parameter for example - http://hostnam:port/context-path/login.do?url="currentURL".

in your login page once the user is authenticated,redirect to the currentURL.


-Sujata.
 
 
subject: Redirect user to current page after session expire when the user resumes
 
Similar Threads
Session Time out
Maintaining the session in all the JSP pages in the Application.
Redirect user to current page after session timeout without error when user resumes again
Page Expired but Session is active
My session expire even while I working on it