• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 249
  • Last Modified:

How to refresh Session variables on browsers' back button

Hi, I have assigned page ids to different pages in my web application using a session variable called page_id. It is done by simply putting following code in body of each page with different page number assigned to each page.        
       <%
            session.setAttribute("page_id","1");
        %>
 It works fine but if user uses browsers' forward or back button, it makes no changes to the session variables value. Is there someway to overcome this problem.

Thanks
0
cool_baba
Asked:
cool_baba
  • 2
  • 2
1 Solution
 
rrzCommented:
The session object should hold user data. For a page id, I would use  
       <%
            pageContext.setAttribute("page_id","1");
        %>  
0
 
cool_babaAuthor Commented:
Tell me if i am wrong. Session variables can be accessed from any page and pageContext variables are bound to only one page. What if i want to know from which page user asked for a particular service or request of data from database ? I dont want to use GET or POST for it to send page id to server with request.

Thanks
0
 
rrzCommented:
I misunderstood your question.  
>Session variables can be accessed from any page and pageContext variables are bound to only one page.  
Yes
>What if i want to know from which page user asked for a particular service or request of data from database ?  
You were right to use session.  
>I dont want to use GET or POST for it to send page id to server with request.
What do you want to use ?
>It works fine but if user uses browsers' forward or back button  
The problem  with these is that the browser wants to cache copies of your pages. Have you tried using what bloodredsun has suggested at  
http://www.experts-exchange.com/Web/Web_Languages/JSP/Q_21442362.html
0
 
cool_babaAuthor Commented:
>I dont want to use GET or POST for it to send page id to server with request.
What do you want to use ?
GET or POST can be used as an alternate for session variables so i told you in advance that i am not interested in using them just in case if you would suggest me to use.

>It works fine but if user uses browsers' forward or back button  
The problem  with these is that the browser wants to cache copies of your pages. Have you tried using what bloodredsun has suggested at  
http://www.experts-exchange.com/Web/Web_Languages/JSP/Q_21442362.html

It works.
Thanks alot
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now