1 28 package net.sf.jasperreports.j2ee.servlets; 29 30 import java.util.ArrayList ; 31 import java.util.List ; 32 33 import javax.servlet.http.HttpServlet ; 34 import javax.servlet.http.HttpServletRequest ; 35 36 import net.sf.jasperreports.engine.JasperPrint; 37 38 39 43 public abstract class BaseHttpServlet extends HttpServlet 44 { 45 46 47 50 public static final String DEFAULT_JASPER_PRINT_LIST_SESSION_ATTRIBUTE = "net.sf.jasperreports.j2ee.jasper_print_list"; 51 public static final String DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE = "net.sf.jasperreports.j2ee.jasper_print"; 52 53 public static final String JASPER_PRINT_LIST_REQUEST_PARAMETER = "jrprintlist"; 54 public static final String JASPER_PRINT_REQUEST_PARAMETER = "jrprint"; 55 56 public static final String BUFFERED_OUTPUT_REQUEST_PARAMETER = "buffered"; 57 58 59 62 public static List getJasperPrintList(HttpServletRequest request) 63 { 64 String jasperPrintListSessionAttr = request.getParameter(JASPER_PRINT_LIST_REQUEST_PARAMETER); 65 if (jasperPrintListSessionAttr == null) 66 { 67 jasperPrintListSessionAttr = DEFAULT_JASPER_PRINT_LIST_SESSION_ATTRIBUTE; 68 } 69 70 String jasperPrintSessionAttr = request.getParameter(JASPER_PRINT_REQUEST_PARAMETER); 71 if (jasperPrintSessionAttr == null) 72 { 73 jasperPrintSessionAttr = DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE; 74 } 75 76 List jasperPrintList = (List )request.getSession().getAttribute(jasperPrintListSessionAttr); 77 if (jasperPrintList == null) 78 { 79 JasperPrint jasperPrint = (JasperPrint)request.getSession().getAttribute(jasperPrintSessionAttr); 80 if (jasperPrint != null) 81 { 82 jasperPrintList = new ArrayList (); 83 jasperPrintList.add(jasperPrint); 84 } 85 } 86 87 return jasperPrintList; 88 } 89 90 91 } 92 | Popular Tags |