File uploading is a very common task in web applications and it is frequently necessary to upload a file from client to server. In HTML forms the input type “file” allows the visitor browse the local file system to select the file. When the file is selected it is sent to server as a part of a POST request. During this there are two mandatory restrictions applied to the form with input type file: it must contains attribute enctype set to value multipart/form-data and its method should be POST. Thus, entire request in sent to server in encoded form. JSP container does not parse the content of requests with type multipart. That is why JSP or servlet processing incoming file data has to use own means to handle request and extract a file from there.

We will use Apache commons FileUpload to handle the file on server.
Once it is downloaded, we should copy the jar files under WEB-INF/lib of our application. If we put a library into lib directory newly, we should be aware of the fact that we need to restart Tomcat. >> Continue Reading


Development, JSP & Servlets - Posted by admin on April 18, 2010

No Comments