jsp网站开发四“酷”全书原码
源代码在线查看: photo.jsp
FileInputStream is = null;
DataInputStream in = null;
try{
String photo = (String)request.getParameter("photo");
photo = oa.main.ParentBean.FilesPath + "news/img/" + photo;
photo = (new oa.main.DealString()).Replace(photo,"\\","/");
is = new FileInputStream(photo);
in = new DataInputStream(is);
response.reset();
if(photo.indexOf("gif")!=-1)response.setContentType("image/gif");
else if(photo.indexOf("jpg")!=-1)response.setContentType("image/jpg");
else if(photo.indexOf("png")!=-1)response.setContentType("image/png");
else if(photo.indexOf("bmp")!=-1)response.setContentType("image/bmp");
else if(photo.indexOf("jpeg")!=-1)response.setContentType("image/jpeg");
byte[] b = new byte[1024];
int len;
while((len=in.read(b)) >0)
response.getOutputStream().write(b,0,len);
}finally{
if(in!=null) in.close();
if(is!=null) is.close();
}%>