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

Forward or Redirect

 
sandhya menon
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am confused in using either of this. In my case when ResultSet found I redirect to NoRecords.jsp else MainMenuDsp.jsp. But I make sure that all Database related objects con,stmt,rs get closed before forward action. But still doubts whether closing conn take place properly. I favoured forward just becuase it seems to be faster than sendRedirect...
Pls comment
 
Bosun Bello
Ranch Hand
Posts: 1510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It depends on what you are trying to achieve. SendRedirect actutally sends a response back to the client after which the client is taken to the specified URL. The request object is no longer available then. Forward passes on the request to the destination page.
You can search this and the Servlets forum for more info.
 
Nasser Aboobaker
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sandhya,
when you do a forward from a servlet the URI will not change. I had a situation where I have a top.jsp which has some buttons and graphics included in every pages of my project. So when I forward from one servlet to a jsp page because the URI does not change the top part of the jsp page did not displayed properly. (The grphics does not load, only text loads correctly).
So I had to change it to redirect.
forward will take you directly to the forwarded page where as redirect will redirect back to client and send another query for the redirected page. speeeed mmmmm may be.
Nasser
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic