interestingly enough, none of the explanations address the
possibility of the url being another remote machine, whence
the differences are clearly emphasized.
geo
"Craig R. McClanahan" wrote:
>
> 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