0

Possible Duplicate:
How to upload files in JSP/Servlet?
File Uploading with Servlets?

I am using Glassfish. How can i upload a file/image/song using a servlet ? After the user clicks the upload button in the form the servlet should handle that data and should copy it at a defined location on server.

Will the method be different if do this on some other server such as Tomcat ?

Community
  • 1
  • 1
Suhail Gupta
  • 22,386
  • 64
  • 200
  • 328
  • Duplicate of http://stackoverflow.com/questions/949417/uploading-a-file-in-java-using-a-servlet and http://stackoverflow.com/questions/4187807/file-uploading-with-servlets. A servlet is a servlet. It doesn't matter which servlet container you use. – JB Nizet Mar 09 '12 at 18:13
  • @ JB Nizet My IDE doesn't show the package `org.apache.commons.fileupload.` But it only shows `org.apache` not commons. What could be the reason for this. I had thought this may be due to different container. – Suhail Gupta Mar 09 '12 at 18:25
  • @ BalusC My IDE doesn't show the package org.apache.commons.fileupload. But it only shows org.apache not commons. What could be the reason for this. I had thought this may be due to different container. – Suhail Gupta Mar 09 '12 at 18:27
  • The reason is because you don't have it as one of your project's dependencies. – Dave Newton Mar 09 '12 at 18:32
  • @ Dave Newton couldn't understand your point. – Suhail Gupta Mar 09 '12 at 18:36
  • 2
    Your IDE doesn't show every possible library in the world. If you want to use a library, download it, read its documentation, and include it in your project. – JB Nizet Mar 09 '12 at 19:17
  • This answer will help you add a compile-time dependency between your NetBeans project and a jar file. http://stackoverflow.com/questions/1975973/how-to-use-jar-files-in-netbeans – vkraemer Mar 09 '12 at 23:08

0 Answers0