📄 showimg.jsp
字号:
<%@ include file="../sys/sessioncheck.jsp"%><html>
<HEAD>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="0">
</HEAD>
<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="java.io.FileOutputStream"%>
<%@ page language="java" %>
<%@ page import="java.io.*"%>
<%@ page import="com.infodeliver.hr.util.DBUtil"%>
<%@ page import="com.infodeliver.hr.util.DBConnection"%>
<%@ page import="com.infodeliver.hr.util.ResultHandler"%>
<%@ page import="java.sql.ResultSet"%>
<%@ page import="com.infodeliver.hr.person.form.PersonActionForm"%>
<%
String strPathFile = application.getRealPath("");
String strPathFile1 = application.getRealPath(request.getServletPath());
System.out.println(strPathFile);
System.out.println(strPathFile1);
String personid = null;
final PersonActionForm personActionForm = new PersonActionForm();
personid = request.getParameter("person_id");
DBConnection conn = session.getAttribute("DBConnection");
String sql = "select * from pr_person where person_id = " + personid;
try {
DBUtil.ProccessSql(conn, sql, new ResultHandler() {
public void proccess(ResultSet rs) throws Exception {
InputStream imgin =rs.getBinaryStream("picture");
personActionForm.setImg(imgin);
}
});
}
catch (Exception ex) {
ex.printStackTrace();
}
InputStream in=personActionForm.getImg();
String imgpath = null;
imgpath=strPathFile+"\\upload\\"+personid+".jpg";
FileOutputStream out1 = null;
try {
out1 = new FileOutputStream(imgpath);
}
catch (Exception ex) {
ex.printStackTrace();
}
response.reset();
response.setHeader("progma","no-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires",0);
response.setContentType("image/jpeg");
byte[] b = new byte[1024];
int len;
while((len=in.read(b)) >0)
{response.getOutputStream().write(b,0,len);
out1.write(b,0,len);
in.close();}
out1.close();
PersonActionForm eform = (PersonActionForm)session.getAttribute("personForm");
eform.setImppath(imgpath);
session.removeAttribute("personForm");
session.setAttribute("personForm",eform);
%>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -