aspose file tools*
The moose likes JSP and the fly likes browser back button problem. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "browser back button problem." Watch "browser back button problem." New topic
Author

browser back button problem.

Vaithialingam Asai
Greenhorn

Joined: Mar 07, 2004
Posts: 10
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

Joined: Nov 15, 2004
Posts: 1026
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.


Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
Vaithialingam Asai
Greenhorn

Joined: Mar 07, 2004
Posts: 10
Thanks for information.

I will be happy If you can tell me how can I handle this situation.
Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: browser back button problem.
 
Similar Threads
facing problem with "redirect" in Tiles
help needed,very urgent
TreeItem renders with extra line in IE8
problem with HTML link in portlet
problem with hyperlink