title: Calling service() of servlet from another servlet
body: <p>I have a url-mapping in my <code>web.xml</code> such that requests for a specific url <code>x.pt</code> gets mapped to a Servlet say <code>Servlet1</code>. In the <code>service()</code> of this servlet I check if the request has some specific parameter.</p>
  
  <p>If so, the call is delegated to another servlet <code>Servlet2</code> by instantiating it and calling its service method.</p>
  
  <pre><code>public void service(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
  
      // if the call is for some special events (request has some specific parameter)
      if (req.getParameter(conditionCheck()) {
          doPost(req, res);
      } else {
          // Report parsing
      }
  }
  
  public void doPost(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
  
      try {
          // instantiate Servlet2 object
          servlet2.init(this.getServletConfig());
          servlet2.service(req, res);
          servlet2.destroy();
      } catch (Exception e) {
          LOG.error("Unable to execute event", e);
      }
  }
  </code></pre>
  
  <p>The browser returns some JSON text when the request is for special events( i.e. to Servlet2)
  Do let me know if I need to do something extra for getting response of Servlet2 to the brwoser. </p>
  
  <p>Thanks in advance!</p>