aspose file tools*
The moose likes Servlets and the fly likes Few doubts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Few doubts" Watch "Few doubts" New topic
Author

Few doubts

R Bhatia
Greenhorn

Joined: Nov 15, 2004
Posts: 9
Hi,

Please let me know in detail :

1. requestDispatcher
2. sendRedirect
3. forward

It will be great if one can provide me difference between above three and which one is to be used preferably.

Regards,
R S
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
read the docs. there is no other better substitute.
Krishna Mohan V
Greenhorn

Joined: Mar 16, 2004
Posts: 20
Hi,

Forward :

When a user asks for a resource, next page is rendered as a response.Just it is a way of displaying the page when a resource is asked by a user.
It is achieved using requestDispatcher.

RequestDispatcher rd = Requestdispacther.getRequestDispather(uri);
rd.forward(HttpServletRequest, HttpServletResponse);

Redirect :

When a user asks for a resouce, server sends a response, which is not the actual requested resource. It does by sending repsonse code of 302 and a URL of the requested resource.
The browser automatically makes a request with this URL and gets the resource.
Thus there is round trip operation between the client and the server. so it should be used in special purposes by using the methods
sendRedirect()...




Go through the documents for further understanding..

Thanks
Krishna Mohan.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

"R S B",
You have already been asked to change your display name here and here.

We're light on rules, but we take display names quite seriously. You can read the full report here, but basically we require your display name to be two words: your first name, a space, then your last name. Fictitious names and initials aren't allowed.

Please edit your profile and correct your display name, since accounts with invalid display names get deleted, often without warning.

thanks,
Dave
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

"Rajat",

Originally posted by David O'Meara:
...basically we require your display name to be two words: your first name, a space, then your last name.


Sorry, but we need two words: your first and then last name, separated by a space
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Few doubts
 
Similar Threads
Is it really a ghost?
Is there any important difference in 1.3 and 1.4 Deployment Description ?
BorderLayout
Design patterns
classic tag inside a simple tag