1 29 package net.sf.jasperreports.ebank; 30 31 import java.io.*; 32 import java.util.*; 33 import javax.servlet.*; 34 import javax.servlet.http.*; 35 36 37 41 public class ImageServlet extends HttpServlet 42 { 43 44 45 48 public void service( 49 HttpServletRequest request, 50 HttpServletResponse response 51 ) throws IOException, ServletException 52 { 53 Map imagesMap = ((ReportBean)request.getSession().getAttribute("reportBean")).getImagesMap(); 54 55 if (imagesMap != null) 56 { 57 String imageName = request.getParameter("image"); 58 if (imageName != null) 59 { 60 byte[] imageData = (byte[])imagesMap.get(imageName); 61 62 response.setContentLength(imageData.length); 63 ServletOutputStream ouputStream = response.getOutputStream(); 64 ouputStream.write(imageData, 0, imageData.length); 65 ouputStream.flush(); 66 ouputStream.close(); 67 } 68 } 69 } 70 71 72 } 73 | Popular Tags |