"Kyle" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Possibly a bit off-topic, but I like to gather some opinions on
> preferences, modes of working, etc. when sending redirects to session
> timeouts and the like pls.
>
> I have Tomcat behind Apache and my error/timeout pages are mostly .html as
> opposed to .jsp
>
> AFAI understand it, response.sendRedirect() sends its response to the
> client first before re-directing the client to the new URL.
> And request.getRequestDispatcher().forward() does it all Tomcat's side
> before sending it back.
>
> Consequently, I would expect request.getRequestDispatcher().forward() to
> be faster. But that's not the way it seems to happen to me.
>
> What do others feel? What are your experiences? And generally how do you
> handle it pls?
>
> Or is there simply some fundamental I have overlooked?
>
Using response.sendRedirect() sends a very small message back to the client,
who then issues another Request on the same open Socket for the new URL.
Unless you have a lot of network latency (e.g. a dial-up connection), this
will be very fast. It's likely that beating the rd.forward() will depend a
lot on if you are using the new Http11-APR connector or not.
The main difference between using rd.forward() and request.sendRedirect() is
the path that the browser thinks that it is seeing. For example, if your
Servlet does:
RequestDispacher rd = request.getRequestDispatcher("subdir/mypage.html");
rd.forward(request, response);
and 'subdir/mypage.html' has an <img src="supercool.gif" /> tag, than the
browser will attempt to load 'supercool.gif' from the directory of the
original Request, and not for the 'subdir' directory.
> --
> ------------------------------------------------------------------------
> Kind Regards
>
> Kyle
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]