Java Servlets

Multiple Included JSP

String firstTable, secondTable, thirdTable;

if (someCondition) {
  firstTable = "/WEB-INF/Sports-Scores.jsp";
  secondTable = "/WEB-INF/Stock-Prices.jsp";
  thirdTable = "/WEB-INF/Weather.jsp";
} else if (...) { ... }

RequestDispatcher dispatcher =
  request.getRequestDispatcher("/WEB-INF/Header.jsp");
dispatcher.include(request, response);

dispatcher = request.getRequestDispatcher(firstTable);
dispatcher.include(request, response);

dispatcher = request.getRequestDispatcher(secondTable);
dispatcher.include(request, response);

dispatcher = request.getRequestDispatcher(thirdTable);
dispatcher.include(request, response);

dispatcher = request.getRequestDispatcher("/WEB-INF/Footer.jsp");
dispatcher.include(request, response);

José M. Vidal .

84 of 89