?
Solved

How to refresh Session variables on browsers' back button

Posted on 2006-05-21
4
Medium Priority
?
236 Views
Last Modified: 2010-04-01
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
Comment
Question by:cool_baba
  • 2
  • 2
4 Comments
 
LVL 28

Expert Comment

by:rrz
ID: 16730823
The session object should hold user data. For a page id, I would use  
       <%
            pageContext.setAttribute("page_id","1");
        %>  
0
 

Author Comment

by:cool_baba
ID: 16731228
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
 
LVL 28

Accepted Solution

by:
rrz earned 1000 total points
ID: 16731355
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
 

Author Comment

by:cool_baba
ID: 16731409
>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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

LinkedIn blogging is great for networking, building up an audience, and expanding your influence as well. However, if you want to achieve these results, you need to work really hard to make your post worth liking and sharing. Here are 4 tips that ca…
With more and more companies allowing their employees to work remotely, it begs the question: What are some of the security risks involved with remote employees and what actions should we take to secure them?
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question