Call servlets from controller servlet

Posted on 2005-04-27
Last Modified: 2013-11-24
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?


Question by:jkavx
    LVL 15

    Expert Comment

    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) ->
    LVL 15

    Accepted Solution

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
    Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
    Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
    Video by: Michael
    Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now