Only 49 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

sendRedirect() or jsp:forward ----?  RSS feed

 
umar hathab
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have one jsp page which I am submitting.In the submitted page ,I am doing some operations and depending on the result ,I want to go to some other pages...Here I have two options .
1) I can use response.sendRedirect()
2) jsp:forward
I want to know which solution will be better..
I know that jsp:forward will take request object ..
I want to know is there any performance issues in selecting a particular solution..
Thanks..
A.Umar
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This has been discussed several times. you can search the forum for more info.
In a nutshell, SendRedirect actually sends a response and status code back to the client, in which case the browser makes another request, hence, the original request object is lost. Forwarding actually passes on the same request.
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Doing a response.sendRedirect() does a client-side redirect whereas the jsp:forward simply forwards processing to another component in your web application - like doing a RequestDispatcher.forward().
Basically, it depends on what you want to do. Typically you would use a "forward" to chain pieces of functionality (components) together, and only use the sendRedirect() when you specifically need to tell the client browser to go to another page.
Hope that helps
Simon
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!