• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
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
 
Manoj Pooleery
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are a couple of things to be noted between the two - forward() and sendRedirect().
forward() works better when one component must perform business logic and share the results with another component. sendRedirect() works best for redirecting from one page to another.
forward() operates within the server and executes faster than a sendRedirect(), which requires a round-trip communication with the client.
However, you can use only relative URLs with forward(), while sendRedirect() works with absolute URLs. This poses its own problems, as if your page has relative links(to images etc), if you use forward, there is a good chance they they will end up as broken links. Hence, it will be better to use sendRedirect() whenever possible and use forward() only when required.
Thanks
Manoj.
[ July 10, 2002: Message edited by: Manoj Pooleery ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!