Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Uploading a image

 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there, supposing you have an HTML page (or jsp, or servlet)
with the code:

And supposing the file was an image(jpg or bmp or something else),
is it possible to get the SomeServlet servlet to store the image
in a folder, to be used later on in the web application?

Thanks for any help
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64982
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. Please see the JSP FAQ.
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, I found an example...



but I dont get it. I won't have a list of items, just one file,
from 1 INPUT tag. Is it necessary in this case to use the
org.apache.commons package, or can I store 1 file without it?

Thanks
 
dema rogatkin
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe you can get it just by name?
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The protocol supports multiple files in one upload. If you only have one it will still work just fine. I'd stick with the code as-is if it's working for you.

The Apache code is doing lots of tricky stuff for you. Browse the code or download Jason Hunter's MultiPartParser and see just how much. I wrote my own for a server that is not J2EE servlets, and it was a significant bit of work. For grins, also look at the Fitnesse server which does the same job in far fewer lines of code than any of those others.
[ March 17, 2006: Message edited by: Stan James ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic