sendRedirect(URL) sends a header back to the browser that tells it load from a new page
the URL. Therefore the original request and response is lost to the next page URL.
Where the request dispatcher insteads invokes the new page directly and if it is
a servlet passes the request and response objects onwards. The browser never
knows what there was a transfer from one servlet to another.
Caveat: Request dispatch only works on inside one web application.
That is
localhost:8080/app1/servlet/ThisServlet
cannot request dispatch to
localhost:8080/app2/servlet/AnotherServlet
So if you want to do that between web applications (and different machines)
you have to use `request.sendRedirect(URL)'.
--
Peter Pilgrim
G.O.A.T
"the Greatest Of All Time"
---------------------------------------- Message History
----------------------------------------
From: Kyle Burke <[EMAIL PROTECTED]>@java.sun.com> on 28/02/2001 00:54 EST
Please respond to "A mailing list for discussion about Sun Microsystem's Java
Servlet API Technology." <[EMAIL PROTECTED]>
DELEGATED - Sent by: "A mailing list for discussion about Sun Microsystem's Java
Servlet API Technology."@java.sun.com>
To: [EMAIL PROTECTED]
cc:
Subject: Re: fordward servlets
Although this will work just fine, it is less elegant than Robert's solution
of "RequestDispatcher.forward(request,response)".
I have always used "response.sendRedirect(URL)" when some sort of error
occurs within the currently executing Servlet.
Can anyone shed some more light on this topic? Do we even have access to
'req' and 'res' the objects with "sendRedirect(URL)" or are they out of
scope? Suppose I'll test it.
--<CUT>--
--
This e-mail may contain confidential and/or privileged information. If you are not the
intended recipient (or have received this e-mail in error) please notify the sender
immediately and destroy this e-mail. Any unauthorised copying, disclosure or
distribution of the material in this e-mail is strictly forbidden.
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html