to display the image you would write a servlet that returns the right content type (image/gif, image/jpeg, etc.), reads the byte[] from the db with Torque, and outputs the byte[] contents to the ServletOutputStream.
To upload an image, you would use a multipart form with an input type=file. Check out Struts to see an example of how to handle uploaded files on the server. Somewhere in your own process-upload action you would get a byte[] with the contents of the uploaded file, and pass it to setPicture(byte[]). -- Bill ----- Original Message ----- From: "Michael Schmitt" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, March 19, 2003 8:11 AM Subject: How to read/write images to/from db > Hi, > probably, this is not the right mailing list for my question, but since I > use Torque to access the data, I hope that someone may answer my > question. > My schema schema definition looks something like this: > ... > <table name="item"> > <column name="id" required="true" type="INTEGER" primaryKey="true"/> > ... > <column name="picture" required="false" type="BLOB"/> > </table> > .... > (db: MySql) > > I want to write a JSP/Servlet (running on tomcat 4.1.18) that shows the > details > and the image of an 'Item'. But I don't know how to get the image from the > db. > Do I have to write a servlet that delivers the image? If so, how to write > it? > Also, I want to offer another JSP/HTML or whatever that enables a user to > upload the image. But I don't know to upload and how to write it to the db. > The > generated Java-class offers the method 'setPicture(byte[])', but where to > get the > byte[] from? > > Any help will be welcomed, > michael > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
