Hi,
Will I be able to call another servlet using sendRedirect or
RequestDispatcher? If so, will the data in the http session also be passed
to the second servlet? If I use RequestDispatcher, can I assume that the
request object being passed to the second servlet has the same data as the
request object in the first servlet unless attributes have been added or
modified in the first request object before the Requestdispatch is called?
Thanks.
Robert
[EMAIL PROTECTED] on 02/11/2000 02:52:57 PM
Please respond to [EMAIL PROTECTED] @ INTERNET
To: [EMAIL PROTECTED] @ INTERNET
cc:
Subject: Re: difference between sendRedirect and
RequestDispatcher...
Rick L Sample wrote:
> What is the difference between using:
>
> ...
> if (session == null) {
> res.sendRedirect("http://localhost:8080/error.html");
> }
> ...
>
This causes a "redirect" message to be returned to your browser (along with
the new URL). If you're on a slow Internet connection, the extra time it
requires will be quite visible.
>
> as opposed to:
>
> ...
> String url="/jsp/shopping/EShop.jsp";
> ServletContext sc = getServletContext();
> RequestDispatcher rd = sc.getRequestDispatcher(url);
> rd.forward(req, res);
> ...
>
This happens on the server side only -- it's basically a subroutine call that
delegates the generation of this response to the servlet (or JSP page) you
forward to. As compared to the sendRedirect() approach going to the same
page, this should be faster. One side effect is that the "location" URL
displayed by your browser does not change -- the browser has no clue you did
anything.
Craig McClanahan
___________________________________________________________________________
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
___________________________________________________________________________
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