wood burning stoves 2.0*
The moose likes JSP and the fly likes Uploading an Image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Uploading an Image" Watch "Uploading an Image" New topic
Author

Uploading an Image

Mary Cole
Ranch Hand

Joined: Dec 02, 2000
Posts: 362
I need to upload an image from the client machine into the database as blob using the JSPs.
Can somebody gimme a sample code how to proceed.
Thx in advance
Bill Siggelkow
Ranch Hand

Joined: Jun 27, 2001
Posts: 57
Mary,
Basically you want to upload to a servlet not to a JSP. Consider the following client application code that receives the file name to upload and the URL of the servlet as arguments ...

Then you would write a servlet to read the input stream and then store the bytes to a file or possibly as a blob in a database as follows ...

[This message has been edited by Bill Siggelkow (edited December 04, 2001).]


Bill Siggelkow
Jade Cove Solutions
Mary Cole
Ranch Hand

Joined: Dec 02, 2000
Posts: 362
Hi Siggelkow,
My requirement is like this ----
I have a data entry screen on the browser.In the screen I have a field to upload the company logo .The company logo will be on the users machine.How do i read the image on the server side(using servlets/jsp) and update my database .
Can Ur sample program is flexible for this?
PL lemme know
Thx in advance

Bill Siggelkow
Ranch Hand

Joined: Jun 27, 2001
Posts: 57
Mary,
No ... the program I gave you is a client-side application ... if you are uploading via an HTML form from a browser your servlet needs to process what is known as multipart form data ... It is non-trivial but you can use classes from oreilly to do help ... go to http://www.servlets.com
Also, you may want to look into the Struts web application framework http://jakarta.apache.org/struts
Mary Cole
Ranch Hand

Joined: Dec 02, 2000
Posts: 362
Can U pl tell me how to update a blob into the database
I have a data entry screen on the browser.In the screen I have a field to upload the company logo .The company logo will be on the users machine.How do i read the image on the server side(using servlets/jsp) and update my database(i need to update the DB not insert into DB) .
Thx in advance
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Uploading an Image
 
Similar Threads
Loading image file
Getting rid of Java Icon on the upper left hand corner
Easy one
Unsupported Color Conversion Request
converting png to tiff and character recognition with tesseract