Call servlets from controller servlet

I need to be able to call n number of servlets from a controller servlet, and build a final html string by handling the response from each of the servlet calls.  How do I call these servlets from the controller servlet?


Who is Participating?
Two corrections:
1. Typo: from your httpservletrquest obtain RequestDispatcher
2. subclass HttpServletResponseWrapper and pass to the RequestDispatcher (instead of

For example of how to use the HttpServletResponseWrapper see
The link explains how to use it with Filter but the concept is the same.
You can try this API calls:
1. from your httpservletrquest obtain getRequestDispatcher ->
2. for each servlet you want to invoke call ->, javax.servlet.ServletResponse)
Where you can wrap the Servlet response with a subclass of ServletResponseWrapper (so you can take the servlet response back the same way Filter does) ->
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.