title: JSP helper class for printing content
body: <p>I have a question on code reuse in JSP. I have a JSP page <code>example.jsp</code> that issues a call to a database and gets the results. I have a java class <code>HelperClass.java</code> that accepts a record and prints out the different fields </p>
  
  <pre><code>response.getWriter().println
  </code></pre>
  
  <p>Now my JSP page has HTML as well and the problem is the content printed out by the HelperClass appears before the content in the JSP page. E.g.</p>
  
  <pre><code>&lt;body&gt;
      This is the first line &lt;br/&gt;
      HelperClass.printdata("second line"); 
  &lt;/body&gt;
  </code></pre>
  
  <p>output is </p>
  
  <pre>secondline This is the first line
  
  </pre>
  
  <p>Is this a known issue. What is the best way to design an <code>HelperClass</code> for a JSP page that prints content out to the page. Any pointers would be greatly appreciated.</p>