JSP输出图片

<%@page import="java.io.File"%>
<%@page import="javax.imageio.ImageIO"%>
<%@page import="java.awt.image.BufferedImage"%>
<%
	String picUrl = request.getParameter("src");
	if (null != picUrl && !"".equals(picUrl.trim())){
		File pic = new File(picUrl);
		if (pic.exists()){
			System.out.print("File found!");
			BufferedImage bImage = ImageIO.read(pic);
			ImageIO.write(bImage,"JPEG",response.getOutputStream());
			out.clear();
			out = pageContext.pushBody(); 
		}else{
			System.out.print("File not found!");
		}
	}
%>
 

你可能感兴趣的:(java,jsp)