title: How to send Data to JSP from a Servlet?
body: <p>I am working on a project which has just one page(index.jsp) and initial load of the page an Ajax request is being sent and JSON data is retrieved.  The AJAX call sent to my Servlet and Servlet returns JSON data,and i have only one Servlet. I am trying to send the some data to my JSP page to populate, so This is how i am writing my Servlet......</p>
  
  <pre><code>protected void doGet(HttpServletRequest request, HttpServletResponse response) throws  ServletException, IOException {
      response.setContentType("text/html");
      PrintWriter out =response.getWriter();
      String queryString = request.getQueryString();
              ResourceBundle props = ResourceBundle.getBundle("jira");
  
      XmlMerge xmlMerge = new XmlMerge();
      String mergeFiles=xmlMerge.getJsonData();
  
      out.println(mergeFiles);
      out.close();
           //Debug Statement
          System.out.println(xmlMerge.getTodo());
          // *THIS IS THE WAY I AM SEND DATA TO JSP PAGE.*
      request.setAttribute("todo", xmlMerge.getTodo());
      request.getRequestDispatcher("/index.jsp").forward(request, response);
  }
  </code></pre>
  
  <p>and in my index.jsp</p>
  
  <pre><code>&lt;%=(String)request.getAttribute("todo")%&gt;
  </code></pre>
  
  <p>I am trying to output the result.</p>
  
  <p>What is going wrong?</p>