File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes How can I get correct backto page? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "How can I get correct backto page?" Watch "How can I get correct backto page?" New topic

How can I get correct backto page?

Jingh Yi
Ranch Hand

Joined: Mar 23, 2005
Posts: 90
Hi All,

I'm new here. I need your help with the browser back button. The sequence of the jsp pages are: page 1 -> page 2 -> page 3. On page 2, there is an 'Export to Excel' button. When user clicks on it, it goes back to the servlet and generate an Excel file and downloads it to jsp page 3. Then when user clicks on the Browser back button on page 3, it does not go back to page 2, it goes back to page 1 instead. How can I control the 'backto' page on jsp page 3, which is the excel file page? It is obviously treated as page 2.

Ganeshji Marwaha

Joined: Sep 16, 2004
Posts: 27
a quick hack would be to use response.sendRedirect in ur servlet to get to the JSP page so that page 3 is treated as it should be... I am assuming that the servlet forwards the request to page 3 using requestdispatcher...

-- Ganeshji Marwaha<br />SCJP<br />SCWCD<br />SCBCD<br />MCP, MCP+SB, MCSD
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63867

"Ganesh M",

We're pleased to have you here with us on the Ranch, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Forum Bartender

[Asking smart questions] [About Bear] [Books by Bear]
Jingh Yi
Ranch Hand

Joined: Mar 23, 2005
Posts: 90

Thanks for your reply. I did try to use redirect and it didn't work. The erro message I got is:

Exception happened:
Please call the System Administrator.

The reason is that, we are using STRUTS framework. Every action has to return ActionForward from the executeBody() method. In order to use the redirect, I had to return null for that method and it caused this error.

Any solutions for that?

I agree. Here's the link:
subject: How can I get correct backto page?
It's not a secret anymore!