This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes JSP and the fly likes Uploading images with jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Uploading images with jsp" Watch "Uploading images with jsp" New topic

Uploading images with jsp

sam barker
Ranch Hand

Joined: Apr 26, 2008
Posts: 37
I trying to a HTML file which will let me choose 3 file and upload all of them at once.

There are also some text boxes.
<FORM METHOD=POST ENCTYPE="multipart/form-data" ACTION="FileUpload.jsp">
File to upload: <INPUT TYPE=FILE NAME="upfile1"><BR>
File to upload: <INPUT TYPE=FILE NAME="upfile2"><BR>
File to upload: <INPUT TYPE=FILE NAME="upfile3"><BR>

When subit is clicked the files should be stored on the server and the values in the text boxes should go to the db.I got the db part working[the easiest ]But I have no idea how to pass multiple images at once.

hOW CAN I handle this in upload.jsp
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

See our FAQ on this subject:

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
sam barker
Ranch Hand

Joined: Apr 26, 2008
Posts: 37
Thanks for the link.
I tried it but it giving me a NoClassDefFoundErrorexception.
But I had placed the 3 jar files inside WEB-INF/lib/

May 11, 2008 10:05:48 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.NoClassDefFoundError: org/apache/commons/io/output/DeferredFileOutputStream
at org.apache.commons.fileupload.disk.DiskFileItemFactory.createItem(
at org.apache.commons.fileupload.FileUploadBase.parseRequest(
at org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(
at org.apache.jsp.FileUpload_jsp._jspService(
at org.apache.jasper.runtime.HttpJspBase.service(
at javax.servlet.http.HttpServlet.service(
at org.apache.jasper.servlet.JspServletWrapper.service(
at org.apache.jasper.servlet.JspServlet.serviceJspFile(
at org.apache.jasper.servlet.JspServlet.service(
at javax.servlet.http.HttpServlet.service(
sam barker
Ranch Hand

Joined: Apr 26, 2008
Posts: 37
Hi again,
Thanks a lot..I had download the file..
Works like a charm
I agree. Here's the link:
subject: Uploading images with jsp
It's not a secret anymore!