title: How to convert CSV to HTML table from java
body: <p>i'm trying to display a CSV file in HTML form, I decided to use CSVToTable jquery but if there's an easier way to do it please let me know.</p>
  
  <p>I read that i cannot just ask user to pick their file and then render it, i have to first load the file to the server, so I added a jsp page to get the file and i wrote an Struts Action class to get the file.</p>
  
  <p>loadFile.jsp:</p>
  
  <pre><code>&lt;form name="myForm" method="POST" action="/importAction.do" enctype="multipart/form-data"&gt;
     &lt;input id='fileId' type='file' name='attachmentFile' value='' maxlength='255'/&gt;
     &lt;input type="submit" value="Submit"/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>My importAction Action class:</p>
  
  <pre><code>public ActionForward doAction(ActionMapping mapping, ActionForm actionForm,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
      //how do i get the file and output this to the jsp?
  
      return mapping.findForward("renderCSV"); 
  } 
  </code></pre>
  
  <p>I also have a target JSP with the following:</p>
  
  <p>renderCSV.jsp:</p>
  
  <pre><code>&lt;div id="CSVTable"&gt;&lt;/div&gt;
  
  &lt;script&gt; 
      $(function() {
          $('#CSVTable').CSVToTable('test.csv'); 
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>So the two questions from the above code is:</p>
  
  <p>1) How do I retrieve this file from the JSP in my java class to pass it to the JSP that will render it?</p>
  
  <p>2) In the renderCSV.jsp How do I pass the file I got in my action class into CSVToTable? right now i have 'test.csv' as a placeholder.</p>
  
  <p>I'm open to other sugestions too. 
  Thanks in advance for the help.</p>