Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Uploading an Image

 
Mary Cole
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
Mary Cole
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic