You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Kyle <kl...@attitia.com> on 2005/10/24 00:06:54 UTC
[OT - sort of] response.sendRedirect or request.getRequestDispatcher.forward
...??
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?
--
------------------------------------------------------------------------
Kind Regards
Kyle
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: [OT - sort of] response.sendRedirect or request.getRequestDispatcher.forward
...??
Posted by Kyle <kl...@attitia.com>.
Cheers Bill.
K
Bill Barker wrote:
>
>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.
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: [OT - sort of] response.sendRedirect or request.getRequestDispatcher.forward ...??
Posted by Bill Barker <wb...@wilshire.com>.
"Kyle" <kl...@attitia.com> wrote in message
news:435C097E.6070409@attitia.com...
> 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: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org