title: Print file content in an textarea on the same page
body: <p>I need a single page with a file upload and a text area where the contents of the file are printed in this page.</p>
  
  <p>At the moment I have a jsp file and a servlet:</p>
  
  <p>Part of index.jsp :</p>
  
  <pre><code> &lt;form action="FileReader" ENCTYPE="multipart/form-data" method="POST"&gt;
   &lt;textarea name="textinputarea" rows="14" cols="130" readonly&gt;
    Some text 
   &lt;/textarea&gt;
   &lt;br&gt; &lt;br&gt;&lt;tr&gt;
  
  
    &lt;td valign="top" align="left" height="200" width="33%"&gt;
    &lt;img class="start_img" src="file_Selections.jpg"&gt; &lt;br&gt; 
  
    &lt;input type="hidden" name="MAX_FILE_SIZE" value="100000" /&gt;
    &lt;input type="file" name="user_file" accept="text/xml"&gt;   
    &lt;input type="submit" value="Validate" /&gt; &lt;br&gt;
     &lt;/form&gt;
  </code></pre>
  
  <p>Part of the servlet:</p>
  
  <pre><code>public void doPost(HttpServletRequest request, HttpServletResponse response)      
  String name = request.getParameter("textinputarea");
  (...)
  }else {
  String otherFieldName = item.getFieldName();
  String otherFieldValue = item.getString();}}
  
  (...)
  
  out.println("&lt;html&gt;");
  out.println("&lt;head&gt;");
  out.println("&lt;title&gt;Processing get requests with data&lt;/title&gt;");
  out.println("&lt;/head&gt;");
  
  // body section of document
  out.println("&lt;body&gt;");
  while ((strLine = br.readLine()) != null) {
  
  // Print the content on the console
  out.println(strLine + "&lt;/br&gt;");
   }
   out.println("&lt;/body&gt;");
  
   // end of html document
   out.println("&lt;/html&gt;");
    out.close();
  
    } catch (Exception e) {
   response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString());
   };
   }
  </code></pre>
  
  <p>This  actually prints the content of file in a new page. I tried to give the same name of text area and the "String name = request.getParameter("textinputarea"); "..</p>
  
  <p>Thanks for your time!</p>