Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will request.getRequestDispatcher().forward creates new thread?

Tags:

java

servlets

I have a use case that the request to be dispatched by trimming request URL to same context by setting some attributes with it. Will this be handled in same thread or in new thread?

like image 653
Sabari Avatar asked Dec 15 '22 02:12

Sabari


1 Answers

It will be handled in the same thread. The Servlet specification states

The Container Provider should ensure that the dispatch of the request to a target servlet occurs in the same thread of the same JVM as the original request.

It does seem like this is a recommendation, but most implementations I know of do it in the same thread.

like image 158
Sotirios Delimanolis Avatar answered Mar 16 '23 02:03

Sotirios Delimanolis