On Feb 13, 2014, at 9:42 AM, André Warnier <a...@ice-sa.com> wrote:

> Daniel Mikusa wrote:
>> On Feb 13, 2014, at 8:25 AM, Campbell, Lance <la...@illinois.edu> wrote:
>>> Java 7 & Tomcat 7
>> For future reference, please specify the full version numbers in use.
>>> In a servlet when doing I a RequestDispatcher.forward to another servlet 
>>> does this create a new Tomcat AJP connection or does it reuse the same 
>>> connection ?
>> "Forwards a request from a servlet to another resource (servlet, JSP file, 
>> or HTML file) on the server."
>> http://tomcat.apache.org/tomcat-7.0-doc/servletapi/javax/servlet/RequestDispatcher.html#forward(javax.servlet.ServletRequest,
>>  javax.servlet.ServletResponse)
> 
> I think that this does not really answer the OP's question, or maybe not 
> clearly.
> 
> It is a bit difficult to answer, because in fact it doesn't have anything to 
> do with the connection, and yet..
> 
> Let's try this :
> 
> - It certainly does not create a new connection, be it AJP or otherwise.
> - It doesn't "re-use" the existing connection.  Its is just that the same 
> connection continues to exist while this is taking place, and it just 
> continues to use it to read request data from, and output response data to.
> - It doesn't have anything to do with the Connector through which the 
> connection was established.
> - It is purely internal to the server, say like "ok, I'll use that servlet 
> code to respond to the client, instead of this one.”

That’s what I take as the important part here.  As the JavaDoc says, it happens 
“on the server”.  

Ex:  (forward)

   Browser -> Tomcat -> ServletA - [forward] ->  ServletB -> Response

This is in contrast to a redirect, which would cause the user’s browser to make 
a second request.

Ex:  (redirect)

   Browser -> Tomcat -> ServletA - [redirect] -> Response (3xx)
   Browser -> Tomcat -> ServletB -> Response

Dan


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to