Jump to content

nktripathi87

Members
  • Posts

    1
  • Joined

  • Last visited

nktripathi87's Achievements

Newbie

Newbie (1/14)

  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare

Recent Badges

0

Reputation

  1. Step 1 : In base Jsp(report.jsp) input type="hidden" name="contextPath" value="<%=request.getContextPath() %>" id="contextPath"/> Step 2 : On includesed js(report.js) var contextPath=document.getElementById("contextPath").value; var url=contextPath+"/generateRecptReport.do?method=generateRecptReport; popupWin= window.open(url,'Report','menubar, toolbar, location, directories, status, scrollbars, resizable, dependent, width=1, height=1 left=0, top=0'); Step 3 on struts-config.xml file **Step 4 on Action(Java code)(ReceiptMakerProcessAction.java) public ActionForward generateRecptReport(ActionMapping mapping,ActionForm form, HttpServletRequest request,HttpServletResponse response) throws Exception { logger.info("In generateRecptReport"); String p_company_logo=getServlet().getServletContext().getRealPath("/")+"reports/logo.bmp"; String reportPath="/reports/MSSQLREPORTS/"; String reportName="receiptMemoReport"; ReportsDAO reportdao = (ReportsDAO)DaoImplInstanceFactory.getDaoImplInstance(ReportsDAO.IDENTITY); logger.info("Implementation class: "+reportdao.getClass()); reportName=reportdao.getReceiptReportName(); if(CommonFunction.checkNull(reportName).trim().equalsIgnoreCase("")) reportName="receiptMemoReport"; Connection connectDatabase = ConnectionDAO.getConnection(); Map<Object,Object> hashMap = new HashMap<Object,Object>(); hashMap.put("p_company_logo",p_company_logo); hashMap.put("IS_IGNORE_PAGINATION",true); try { InputStream reportStream = getServlet().getServletConfig().getServletContext().getResourceAsStream(reportPath+reportName+".jasper"); JasperPrint jasperPrint = null; PrintWriter out=response.getWriter(); out.append("<head><script type='text/javascript' src='"+request.getContextPath()+"/js/report/report.js'></script></head>"); out.append("<body onLoad='self.print();self.close()'></body>"); response.setContentType("text/html"); String htmlReportFileName=reportName+".html"; JRHtmlExporter exporter = new JRHtmlExporter(); request.getSession().setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE,jasperPrint); exporter.setParameter(JRHtmlExporterParameter.OUTPUT_WRITER, out); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN ,Boolean.FALSE); exporter.setParameter(JRHtmlExporterParameter.IGNORE_PAGE_MARGINS ,Boolean.TRUE); exporter.setParameter(JRHtmlExporterParameter.IS_WHITE_PAGE_BACKGROUND,Boolean.FALSE); exporter.setParameter(JRHtmlExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,Boolean.TRUE); exporter.setParameter(JRHtmlExporterParameter.IS_OUTPUT_IMAGES_TO_DIR, Boolean.TRUE); exporter.setParameter(JRHtmlExporterParameter.BETWEEN_PAGES_HTML,""); exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, response.getWriter()); float f1=1.2f; exporter.setParameter(JRHtmlExporterParameter.ZOOM_RATIO ,f1); exporter.exportReport(); } catch(Exception e) { e.printStackTrace(); } finally { ConnectionDAO.closeConnection(connectDatabase, null); hashMap.clear(); } return null; }
×
×
  • Create New...