This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

forwarding problem

 
Sunil K Bansal
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys
I m forwarding from one JSP page(abc.jsp) to aother JSP page(xyz.jsp) for this I m using forward action
<jsp:forward page="xyz.jsp" />
i know when u forward the url in address do not change
but after going to xyz.jsp
when i submit this page it takes back to abc.jsp
I dont want to go back on abc.jsp i want to stay on xyz.jsp only
how to stop this?
Thanx and Regards
Bansal
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a discussion on 'forward' in this thread
Short answer: forward works on the server side. The client (ie the browser) knows nothing about t and can't react to it.
DOM
 
Sunil K Bansal
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
by using
response.sendRedirect("xyz.jsp");
parameters are not getting passed from abc.jsp to xyz.jsp
i need parameters from abc.jsp in xyz.jsp
Bansal
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First I'd suggest playing with forward, since the JSPs share the request and response objects and you can use them to communicate.
If you absolutely need to use sendRedirect (because it is inefficient), you can either put the data on the session (not recommended) or add it to the URL (not recommended for sensitive data)
res.sendRedirect("xyz.jsp?name=Dave");
DOM
 
SAFROLE YUTANI
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to forward the entire request, which include the parameters, from one page to another page, then use the RequestDispatcher class.
On your JSP, execute the following code to send the client to the page of your choice, and let's use "/xyz.jsp" as an example for the page that we will forward the client.
request.getRequestDispatcher("/xyz.jsp).forward( request, response);
That's all you have to do. The request and response objects will be forwarded to the new URI, namely "/xyz.jsp"
SAF
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic