Senthilkumar Annadurai
Senthilkumar Annadurai

Reputation: 418

does control come back to the webapp which forwarded request to another webapp?

I have 2 web apps.

  1. A.war
  2. B.war

both have been deployed in same app server. A request comes to A.war and it forwards the request to B.war via

context.getServletContext("appname of B").getRequestDispatcher("uri").forward(request, response);

once the request is forwarded from A to B and then once the processing is completed on B, does the control come back to web app A or web app B directly sends the request to the client (browser)?

In other words , is it a separate Thread that would be executed in web app B in this case and it sends the response directly to the user?

Upvotes: 2

Views: 56

Answers (1)

itwasntme
itwasntme

Reputation: 1462

As the forward word says when the user's request is forwarded to another webapp/servlet and the element that invoked forward method no longer works and its thread is killed. In both situations, forwarding to another servlet or webapp creates new thread to handle the request.

To move control back to the first servlet/application you should forward your request again.

Upvotes: 3

Related Questions