这是一个JSP显示图片的页面内容
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ page import="login.Login,java.sql.*,java.io.*" %>
Insert title here<%
String workno = request.getParameter("workno");
Login login = new Login();
Connection con = login.conn();
Statement stmt=con.createStatement();
ResultSet rs=null;
String sql = "select photo from rs_photo WHERE workno='"+workno+"'"; //要执行查询的SQL语句
rs=stmt.executeQuery(sql);
while(rs.next()) {
ServletOutputStream sout = response.getOutputStream(); //图片输出的输出流
InputStream in = rs.getBinaryStream(1);
byte b[] = new byte[0x7a120];
for(int i = in.read(b); i != -1;) {
sout.write(b); //将缓冲区的输入输出到页面
//in.read(b);
}
sout.flush(); //输入完毕,清除缓冲
sout.close();
}
%>
现在你可以在你原始的页面上判断workno是否为空,不为空时就window.open()打开这个页面,就可以把图片显示出来了