wood burning stoves*
The moose likes Servlets and the fly likes JSP / Servlet upload images Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "JSP / Servlet upload images" Watch "JSP / Servlet upload images" New topic
Author

JSP / Servlet upload images

Kevin P Smith
Ranch Hand

Joined: Feb 18, 2005
Posts: 362
Hi guys

Just wondering if you could help with my next issue?

i am writing a function that allows the user to upload images/metadata from their localk machine onto my web syste,

this is done in 3 steps:
1. browse to and select images from local hard-disk, click upload > continue
2. goto next page and enter metadata > continue
3. goto next display summary of images and metadata > confirm

now I can do all this except I can't get the upload image thing working.

I think i need to use something like

JSP


Servlet


1. Why does the JSP return NULL for the hidden value 'step' when I put the [enctype="multipart/form-data"] in the <form>>

2. What do I have to do in the Servlet to 'get' the image data?

Any help greatly appreciated

KS
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

There are already libraries out there that make it easy to do this.
See:
http://faq.javaranch.com/java/FileUpload


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

1. Why does the JSP return NULL for the hidden value 'step' when I put the [enctype="multipart/form-data"] in the <form>>


Multipart forms work differently from regular form submissions.
Because of this, request.getProperty doesn't work with them.
The libraries mentioned in the link I gave you all have their own way of retrieving form parameters when uploading.
Kevin P Smith
Ranch Hand

Joined: Feb 18, 2005
Posts: 362
Cheers guys

I'm using the Jakarta Fileupload JAR but have hit a snag!

The files I am uploading are images, which I need to then 'retrieve' on the next JSP page to display.

So far i have this code in the Servlet



Then I need to display the image in a JSP file so was gonna do the usual:



But I'm getting nothing back.
[ March 13, 2008: Message edited by: Keith Seller ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP / Servlet upload images
 
Similar Threads
Posting Multipart Forms in HttpUnit
Help in Multipart Request Urgent
sending a servlet parameters
query regarding present code
mutipart/form-data