pic.jsp
资源名称:0102010.rar [点击查看]
上传用户:nbluoke
上传日期:2013-08-09
资源大小:4851k
文件大小:1k
源码类别:
教育系统应用
开发平台:
WORD
- <%@ page import="java.io.*" import="java.sql.*" %>
- <jsp:useBean id="DBCon" class="jinghua.JinghuaConn" scope="session">
- </jsp:useBean>
- <%
- response.setContentType("image/jpeg");
- Connection Conn = DBCon.getConnection();
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- String id=request.getParameter("ID");
- //从数据库里读取图片
- String sql="SELECT * FROM PHOTOS WHERE ID="+id;
- pstmt = Conn.prepareStatement(sql);
- rs = pstmt.executeQuery();
- rs.next();
- byte[] buffer = rs.getBytes("photo");
- //显示图片
- BufferedOutputStream bos = new BufferedOutputStream(response.getOutputStream());
- bos.write(buffer);
- bos.flush();
- bos.close();
- rs.close();
- pstmt.close();
- Conn.close();
- %>