• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Expire session and show 'invalid session' page when user press browser's back button

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
My requirement is to invalidate session and show a 'session expiry' page whenever user press browser's back button. I am using JSF and richfaces for building web pages.

Could anyone suggest a way to resolve this issue please?

Francis
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am not sure how to go about with JSF, but I had been working on Spring MVC.
Let me explain in generic.

Following will be needed:
1. 2 tokens to identify the current page and the next page in the current JSP.
2. method abc () to be called in all the requests.

Tokens:
------
There will be two hidden variables, currentPage and nextPage in the page.
The currentPage will have a hardcoded value for each page.
The nextPage will take the name of the next page when the event handler is called in javascript.

Session update:
--------------
When the request successfully moves from one page to another, a variable currentPage will be stored in the session with the destination page (nextPage).
This happens before the forward is returned by an action method.

Action Class Update:
-------------------
All the methods of the action class will have to call the super class method abc() which will perform the following:
This will read the currentPage attribute from the request parameter and compare the same with the session variable.
In case, the variables are the same, proceed to perform the action, else redirect to the session invalid page.

Hope this will suffice your requirement.

Rajiv
 
Prince Lukose
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much for your suggestion, Rajiv. This is an interesting solution.

Could you please also explain, how can we perform a server interaction from the previous page when user presses browser's 'back' button? I think, browser will not submit details to server when user press back button. In this scenario, I am afraid, we cannot compare the page tokens in server, and redirect user to 'session expiry' page.

Thanks,
Francis
 
Rajiv Putuval
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Hmm, in my application, I had encountered the page submission whenever I clicked the back button.
So maybe I did not feel that there could be a possibility of the browser not submitting any request.

I am not in a position to analyze how the browser decides whether to submit the page or not.
In this case, it is a browser specific event handling, which is not in the application's control.

Maybe I will have to do a little research on this.
Sorry, I could not be of any help to you at the moment.

Regards,
Rajiv
 
Prince Lukose
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No problem, Rajiv.
I am really thankful to you for spending your time for analysing my problem.

Thanks & regards,
Francis
 
when your children are suffering from your punishment, tell your them it will help them write good poetry when they are older. Like this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic