code: public static void chainRequestDispatchers(RequestDispatcher[] dispatchers, HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException{
          for(int i=0; i<dispatchers.length-1; i++) {
              ChainedResponse chainedResp = new ChainedResponse(request, response);
              dispatchers[i].forward(request, chainedResp);
              request = chainedResp.getChainedRequest();
          }
          dispatchers[dispatchers.length-1].forward(request, response);
      }
docs: Chain the responses of a set of request dispatchers together.