title: What I should do to load a JSP page in a <div> tag in another JSP page through a Servlet?
body: <p>Here is the problem, i have 3 JSP pages (<strong>main.jsp</strong>, <strong>manageClasses.jsp</strong> and <strong>insertDates.jsp</strong>) and 2 Servlets (<strong>AttendanceServlet</strong> and <strong>ManageClassServlet</strong>). The  main page loads the other ones inside itself. </p>
  
  <p>Basically what i want to do is upon calling the AttendanceServlet i want to load insertDates.jsp into main.jsp. Replacing the previous content which was loaded by ManageClassServlet.</p>
  
  <p><strong>main.jsp</strong></p>
  
  <pre><code>&lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
  &lt;!DOCTYPE html&gt;
  
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
          &lt;script type="text/javascript" src="js/jquery-1.7.min.js"&gt;&lt;/script&gt;
          &lt;link rel="stylesheet" href="css/stylesheetprincipal.css"&gt;
          &lt;script type="text/javascript"&gt;  
              $(document).ready(function() {
              $("#gt").click(function(){
                  $("#internal").load('ManageClassServlet');
              });
          });
          &lt;/script&gt;
          &lt;title&gt;Main&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;div id="nav"&gt;
              &lt;ul&gt;
                  &lt;li&gt;&lt;a href="javascript:void(0)" id="gt" title="manage"&gt;MANAGE     CLASSES&lt;/a&gt;&lt;/li&gt;  
                  &lt;li&gt;&lt;a href="logout.jsp" title="exit"&gt;EXIT&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
          &lt;/div&gt;    
          &lt;div id="forms"&gt;
              &lt;div id="internal"&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>ManageClassServlet</strong></p>
  
  <pre><code>@WebServlet(name = "ManageClassServlet", urlPatterns = {"/ManageClassServlet"})
  public class ManageClassServlet extends HttpServlet {
  
      @Override
      public void doGet(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, java.io.IOException {
          HttpSession session = request.getSession();
          String[][] tableMatrix = getTableMatrix(professorClasses);
          session.setAttribute("tableMatrix", tableMatrix);
          response.sendRedirect("manageClasses.jsp");
      }
  }
  </code></pre>
  
  <p><strong>manageClasses.jsp</strong></p>
  
  <pre><code>&lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
  &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
          &lt;title&gt;Manage Classes&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;form action="AttendanceServlet" method="post"&gt;
              &lt;table id="classTable" border="2"&gt;
                  &lt;TR&gt; &lt;TH&gt;&amp;nbsp;&lt;/TH&gt; &lt;TH&gt;Subject&lt;/TH&gt;  &lt;TH&gt;Year/Semester&lt;/TH&gt;  &lt;TH&gt;Frequencias&lt;/TH&gt; &lt;/TR&gt;
                  &lt;c:forEach items="${matrixTable}" var="row" varStatus="i"&gt;
                      &lt;tr&gt;
                          &lt;TH&gt;${row[0]}&lt;/TH&gt;
                          &lt;c:forEach begin="1" end="2" items="${row}" var="value"&gt;
                              &lt;td&gt;${value}&lt;/td&gt;
                          &lt;/c:forEach&gt;
                          &lt;td&gt; &lt;button type="submit" name="Ver" value="${row[3]}"&gt;See    &lt;/button&gt; &lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/c:forEach&gt;
              &lt;/table&gt;
          &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I was trying to use the out Object to send the jsp page but it didnt work.</p>
  
  <p><strong>AttendanceServlet</strong></p>
  
  <pre><code>@WebServlet(name = "AttendanceServlet", urlPatterns = {"/AttendanceServlet"})
  public class AttendanceServlet extends HttpServlet {
  
      @Override
      public void doPost(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, java.io.IOException {
          try {
              ClassDAO classDao = new ClassDAO();
              Integer idClass = Integer.parseInt(request.getParameter("See"));
              ClassBean class = classDao.searchClassBean(idClass);
              if (class.getDateClasses() == null) {
                  String path = "/WEB-INF/jsp/main.jsp";
                  PrintWriter out = response.getWriter();
                  out.println("&lt;script type=\"text/javascript\"&gt;");
                  out.println("$(document).ready(function() {");
                  out.println("$(\"#internal\").load('insertDates.jsp');");
                  out.println("});");
                  out.println("&lt;/script&gt;");
                  RequestDispatcher dispatcher = request.getRequestDispatcher(path);
                  dispatcher.include(request, response);
              }
          } catch (SQLException ex) {
              ex.printStackTrace();
          }
      }
  }
  </code></pre>