title: Best way to transfer data between servlet and jsp?
body: <p><strong>First try:</strong></p>
  
  <p>I'm generating data in servlet and then set it in request as attribute and send that request to jsp by calling requestDispatcher as follows:</p>
  
  <pre><code>request.setAttribute("data",data);
  request.getRequestDispatcher("/page.jsp").forward(request, response);
  </code></pre>
  
  <p>Now access it in jsp and display data.</p>
  
  <p>This works fine but everytime user refreshes page it gets an alert saying you are resubmitting the form and ask for confirmation. This is annoying.</p>
  
  <p><strong>Second try:</strong></p>
  
  <p>Put data in session and access that in jsp page. In this way session gets very heavy as the data amount is big.</p>
  
  <p>So my question is <strong>what is the best way to pass data from servlet to jsp?</strong>
  Here data is object list.</p>