Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

browser back button problem.

 
Vaithialingam Asai
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JSP page in which there are 5 links and 2 Combo box.
When any event(by clicking links or chosing a diffrent value in combo box) is fired on this page, same page is submitted.

On clicking the link the records for that link is displayed (Expanded).
On clickig the link again the expanded record is contracted.

Let me explain with an example (w.r.t to links).

link1
link2
link3
link4
link5

Suppose link2 is clicked.

link1
link2
//Records for link2
link3
link4
link5

link 3 is clicked.

link1
link2
//Records for link2
link3
//Records for link3
link4
link5

If I click the link2 again

link1
link2
link3
//Records for link3
link4
link5

Now when I click the browser back button(from this state).

link1
link2
//Records for link2
link3
//Records for link3
link4
link5

Now the problem is when I click the link5
I get this

link1
link2
link3
//Records for link3
link4
link5
//Records for link5

but It should be


link1
link2
//Records for link2
link3
//Records for link3
link4
link5
//Records for link5


To explain briefly about the code.
On clicking the link, I call a javascript. In the javascript
based on the link clicked I set the flag to expanded(if it is normal)/ contracted (if the link is in expanded mode).
There are flags corresponding to each links.


Can anyone help me?

Thanks in Advance
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whenever you click a link a new request is send to the server. But when you use a Back browser Button your cached page is displayed to you(It doesn't reflect the current state of your application).It's just a stale page. Thats why you expected Records for link2 it was NOT available.
 
Vaithialingam Asai
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for information.

I will be happy If you can tell me how can I handle this situation.
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You CANNOT control users using Back browser Button. That can't be done from server-side code. you can control such operations using JavaScript. Search this forum and servlet forum for code samples.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic