• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
The first person to drink cow's milk. That started off as a dare from this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic