File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Forward or Redirect Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Forward or Redirect" Watch "Forward or Redirect" New topic
Author

Forward or Redirect

sandhya menon
Ranch Hand

Joined: May 22, 2001
Posts: 37
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

Joined: Nov 06, 2000
Posts: 1510
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.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Nasser Aboobaker
Ranch Hand

Joined: Dec 06, 2000
Posts: 104
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Forward or Redirect