Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

JSP uploader

Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to upload a file[ image file or any other file ]
I need the functionality --- user brows a file from client computer
and then press Upload button the backGround jsp/java file upload it to my "tomcat 5.5\webapps\TEST\IMAGES" folder.
any one help me???
write the code.
Posts: 67430
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you checked the FAQs?
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are libraries that are available to help you, and this information is in the FileUpload section of the FAQ. If you would like more information on what happens under the covers then in many cases the source code is available, or you can solve the problem at hand if that is what you need.
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is code works in Struts :

put this code in your jsp for file uploading

<td width="25%">File to be Upload</td>
<td><html:file property="theFile" /></td>

Use this in your Action :
Where uploadForm is an object of form bean with getter and setter methods

FormFile myFile = uploadForm.getTheFile();
String fileName = myFile.getFileName();
System.out.println("File name :"+fileName);

myfile is the uploaded file, Now you got the uploaded file

filepath--- specify the path where new file to be created.

File fileToCreate = new File(filePath, fileName);
//If file does not exists create file
FileOutputStream fileOutStream = new FileOutputStream(fileToCreate);
    Bookmark Topic Watch Topic
  • New Topic