View multiple images in a page
Hi, I'm able to run the following code in the jsp. But my problem is I have multiple images in a table and would like all of it to be display as an icon. I have tried to put while(rs.next())... it doesn't work. How should I go about to do it. Thanks. Tan %@ page import=java.sql.* % %@ page import=java.io.* % %@ page import=javax.servlet.* % %@ page import=javax.servlet.http.* % %@ page import=javax.servlet.jsp.* % % OutputStreamos; String fn,sSQL,contentType,JDBC,DBURL,userName,pwd; int bufferSize=1048576,bytesRead=0; byte[] b = new byte[bufferSize]; ServletOutputStream sos; InputStream is; int fieldCount=0; ResultSet rs; Connection conn; Statement stmt; int fieldNo; Blobblob; BufferedInputStream bis; BufferedOutputStreambos; JDBC=org.gjt.mm.mysql.Driver; DBURL=jdbc:mysql:///imaging; userName=root; pwd=password; sSQL=select Bobject from blobber; fn=1; contentType=image/gif; try {Class.forName(JDBC); conn=DriverManager.getConnection(DBURL,userName,pwd); stmt=conn.createStatement(); rs=stmt.executeQuery(sSQL); if (contentType==null) response.setContentType(image/gif); else response.setContentType(contentType); if (fn==null) fieldCount=1; else fieldCount=Integer.parseInt(fn); rs.next(); blob= rs.getBlob(1); is=blob.getBinaryStream(); bis=new BufferedInputStream(is,2*bufferSize); sos=response.getOutputStream(); bos=new BufferedOutputStream(sos,2*bufferSize); bytesRead=bis.read(b,0,bufferSize); while (bytesRead!=-1) { bos.write(b,0,bytesRead); bytesRead=bis.read(b,0,bufferSize); } bis.close(); bos.close(); is.close(); sos.close(); rs.close(); stmt.close(); conn.close(); } catch (Exception e) { response.setContentType(text/html); PrintWriter out1=response.getWriter(); out1.println(Servlet BlobHandler error occur:+e.toString()); } % __ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: View image from browser
Hi Paul I went to the site and I can't look for the page. If you dont' mind to get the the exact url. Thanks. --- Paul DuBois [EMAIL PROTECTED] wrote: At 23:23 -0800 12/26/02, tan tan wrote: Hi, Is anyone know how to view image that is stored in mysql as binary format to a browser ? Thank you. Once you pull your image data from MySQL (I assume you're using some kind of script for this), then you do this the same way you'd do it if MySQL weren't involved. Send your HTTP headers to indicate the MIME type and the length, a blank line, and the image data. If you want some example code in Perl, get the webdb distribution at http://www.kitebird.com/mysql-perl/ and look in the distribution's image directory. sql, query __ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: View image from browser
Hi, Sorry I didn't check in the pdf. Thanks guys. By the way, I found there is an article from www.onlamp.com/lpt/a/a370 it uses the php to do the same thing. Thanks once again. Tan Tan --- Paul DuBois [EMAIL PROTECTED] wrote: At 0:43 -0800 12/27/02, tan tan wrote: Hi Paul I went to the site and I can't look for the page. If you dont' mind to get the the exact url. Thanks. Odd. Anyone else out there have trouble with that URL? http://www.kitebird.com/mysql-perl/downloads.php http://www.kitebird.com/mysql-perl/webdb/webdb.tar.gz http://www.kitebird.com/mysql-perl/webdb/webdb.zip --- Paul DuBois [EMAIL PROTECTED] wrote: At 23:23 -0800 12/26/02, tan tan wrote: Hi, Is anyone know how to view image that is stored in mysql as binary format to a browser ? Thank you. Once you pull your image data from MySQL (I assume you're using some kind of script for this), then you do this the same way you'd do it if MySQL weren't involved. Send your HTTP headers to indicate the MIME type and the length, a blank line, and the image data. If you want some example code in Perl, get the webdb distribution at http://www.kitebird.com/mysql-perl/ and look in the distribution's image directory. sql, query __ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
View image from browser
Hi, Is anyone know how to view image that is stored in mysql as binary format to a browser ? Thank you. __ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php