1

I am trying to upload a text file from client machine to server. Below is the code I am using in jsp.

<tr>
             <td class="FORMLABEL" nowrap valign=middle>
              &nbsp;&nbsp;<%= fileLabel %>&nbsp;
             </td>
             <td class="FORMELEMENT" nowrap valign=middle>
              <input  size = "50" name="loadFile" type="FILE" >
             </td>
     </tr>

I have checked the content Type of the load file, it is application/x-www-form-urlencoded I need to read the file. How can I copy this file from client machine to the server using JSP?

1 Answers1

0

You need to write a servlet for fileupload

Create a form there and submit to server

<form action="upload" method="post" enctype="multipart/form-data">
    <input type="text" name="description" />
    <input type="file" name="file" />
    <input type="submit" />
</form>

and in servlet

protected void doPost(HttpServletRequest request, HttpServletResponse response)
                  throws ServletException, IOException {
    try { 

--- - - -

-----

Do as shown in How to upload files to server using JSP/Servlet?

}

and also refer this for more info and possibilities.

Community
  • 1
  • 1
Suresh Atta
  • 120,458
  • 37
  • 198
  • 307