• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

JSP / Servlet upload images

 
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are already libraries out there that make it easy to do this.
See:
http://faq.javaranch.com/java/FileUpload
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
If you like strawberry rhubarb pie, try blueberry rhubarb (bluebarb) pie. And try this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic