📄 showimg.java
字号:
package com.laoer.bbscs.servlet;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import com.laoer.bbscs.sysinfo.*;
/**
* <p>Title: 天乙社区V5.0</p>
* <p>Description: BBS-CS天乙社区V5.0</p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: laoer.com</p>
* @author 龚天乙
* @version 5.0
*/
public class ShowImg
extends HttpServlet {
private static final String CONTENT_TYPE = "text/html; charset=UTF-8";
//Initialize global variables
public void init() throws ServletException {
}
//Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
String picdir = request.getParameter("picdir");
if (picdir == null) {
picdir = "";
}
picdir = Sys.SYSINFO.FILEPATH + picdir;
response.setContentType(CONTENT_TYPE);
//PrintWriter out = response.getWriter();
//File fdir = new File(picdir);
//if (!fdir.exists()) {
//}
FileInputStream fis = null;
ServletOutputStream sos = null;
try {
response.setContentType("image/jpeg");
fis = new FileInputStream(picdir);
sos = response.getOutputStream();
byte[] bytes = new byte[1024];
while (true) {
int len = fis.read(bytes, 0, 1024);
if (len != -1) {
sos.write(bytes, 0, len);
}
else {
break;
}
}
}
catch (Exception e) {}
finally {
try {
if (fis != null) {
fis.close();
}
if (sos != null) {
sos.close();
}
}
catch (Exception e) {}
}
}
//Process the HTTP Post request
public void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
doGet(request, response);
}
//Clean up resources
public void destroy() {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -