wood burning stoves 2.0*
The moose likes JSP and the fly likes How to do a jsp:forward on clicking a link/button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "How to do a jsp:forward on clicking a link/button" Watch "How to do a jsp:forward on clicking a link/button" New topic
Author

How to do a jsp:forward on clicking a link/button

Sindhu Ananth
Greenhorn

Joined: Feb 20, 2002
Posts: 5
Hi,
I am building a content upload application using JSPs - I seem to get stuck at one point.
The scenario is like this - There is a JSP page, page A that has a form. Here the user enters some data that he wants to upload to a site. On clicking submit, page A does some validations and forwards to page B. Page B has a link, on clicking this, the user can preview the uploaded data. If he does not like what he sees, page B has a Return link. This should take him back to page A with all the data he entered intact. I am using a Bean that has all the form values, and it is in request scope, so I need to be able to forward to Page A on clicking the return link/button.
I tried to explicitly set the bean in the request, but what happens is on clicking the link, it seems to be a new request entirely. I want to somehow use the same request object when I click this link.
I also tried calling a javascript function on clicking the link, and forwarding inside the function, but then the forward seems to get executed the first time itself, so that page B is never displayed.
Using the bean in session scope is not ok, since I do not want the form data to be valid for the entire browser session, only for the request.
My guess is that there is something simple here that I am missing. Can someone please point me in the right direction?
Thanks so much,
Sindhu
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
u can always do session.removeAttribute() for the bean u added in the session scope...it wont be there in the session object anymore...
i need to try this yet...but i can't try it as i'm using iPlanet 4.1 web server on which i 'm not able to run jsp:useBean etc tags (i don know why tho...)
let me know if this works for u...
regards
maulin
Sindhu Ananth
Greenhorn

Joined: Feb 20, 2002
Posts: 5
That's what I finally did. I was initially reluctant to store in session because then whenever the user clicks on a link to the page, it would display the values. But I guess that is the most painless way, and it works!
Thanks!
Sindhu
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to do a jsp:forward on clicking a link/button