从库中读图片显示到页面上的主要源码

2008-02-23 09:16:09来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

<%@ page contentType="text/html;charset=iso8859_1"%>
<%@ page import="Java.sql.ResultSet"%>
<JSP:useBean id="query" class="pub.MakeDB"/>
<%
String sql = "select * from images";
ResultSet rs = query.executeQuery(sql);
rs.next();
InputStream in = rs.getBinaryStream("image");
ServletOutputStream sos = response.getOutputStream();
int len = 0;
byte[] b = new byte[1024];
response.reset();
response.setContentType("image/gif");
while((len = in.read(b)) > 0)
sos.write(b,0,len);
in.close();
sos.close();
query.cls();
%>
如果是写到文件只要把sos
定义为DataOutputStream sos = new DataOutputStream(new BufferedOutputStream(new FileOutputStream("/a.gif")));

上一篇: 我整理的一个经典分页程序(JSP的)
下一篇: WAP应用开发环境就是这样搭建的

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:JSP初学者看的好文章[推荐]

下一篇:我整理的一个经典分页程序(JSP的)