retrieveing image with jdbc
Connection con = Database.getDBConnection();
Statement stmt = null;
ResultSet rs = null;
try {
stmt = con.createStatement();
rs = stmt.executeQuery("SELECT IMAGE " +
" FROM " + tablename +
" WHERE IMAGEID = " + imageid );
rs.next();
blobData = rs.getBinaryStream("IMAGE");
}
catch (SQLException e) { Utils.trace(e.getMessage()); }
// convert input stream to byte[]
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int count = 0;
try {
int bytesRead = 0;
while ((bytesRead = blobData.read()) != -1)
baos.write(bytesRead);
}
catch(IOException e) { Utils.trace(e.getMessage()); }
with : baos u can do a straight output
PrintWriter out = response.getWriter();
response.setContentType("image/jpeg");
out(baos);
out.close();
this prints the image straight to a separate HTML page
but i see you want text and image on the same page.
u could save all the images on the server and create links to them when
outputting the HTML
u could also use o reilly servlet classes ... it has a MultiPartResponse
class.
There is only one prob with it is that MS IE does not support
MultiPartResponse type.It could be just version 4.0 i'm not to sure ...
someone else may want to post a message to clear that point up.
-----Original Message-----
From: Reto <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Monday, September 27, 1999 12:49 PM
Subject: Examples for JDBC and Servlet / picture in table
>Hi
>
>I'm a beginner in servlet-programming and i'm
>searching source-code examples for a little prject.
>That sevlet must connect to a database (adabas) on
>linux and shows a table with personalinformation
>include a picture. The information and picture comes
>from teh db. For example:
> ---------------------------------------------------
> | Reto Tobler | Street | Place | ------Picture----|
> ---------------------------------------------------
> | Marc Turner | Street | Place | ------Picture----|
> ---------------------------------------------------
> | usw.
>
>If somebody have some source from others project, then
>send me please. Very interest could bee to reading the
>information that comes from the db.
>
>Thank
>
>Reto
>
>__________________________________________________________________
>Do You Yahoo!?
>Gesendet von Yahoo! Mail - http://mail.yahoo.de
>Yahoo! Auktionen - gleich ausprobieren - http://auktionen.yahoo.de
>
>___________________________________________________________________________
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff SERVLET-INTEREST".
>
>Archives: http://archives.java.sun.com/archives/servlet-interest.html
>Resources: http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html