Jump to content
Changes to the Jaspersoft community edition download ×

Jasper Report + Jsp/Servlet


Recommended Posts

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic


Check out the following code. It's a .jsp file in my web application, from this file i'm calling my report. If any queries feel free to revert back.



<%@ page import="java.io.*" %>

<%@ page import="java.sql.*" %>

<%@ page import="java.util.*" %>

<%@ page import="peoplewarejava.*"%>

<%@ page import="net.sf.jasperreports.engine.*" %>

<%@ page import="net.sf.jasperreports.engine.xml.JRXmlLoader"%>

<%@ page import="net.sf.jasperreports.engine.design.JasperDesign"%>

<%@ page import="net.sf.jasperreports.j2ee.servlets.*" %>

<%@ page import="net.sf.jasperreports.view.*"%>

<%@ page import="net.sf.jasperreports.engine.util.*" %>

<%@ page import="net.sf.jasperreports.engine.export.*" %>


JasperDesign jasperDesign= JasperManager.loadXmlDesign(getServletContext().getRealPath("/")+"reports/BirthdayPie.jrxml");

JasperReport jasperReport = JasperManager.compileReport(jasperDesign);

Map parameters = new HashMap();

parameters.put("ReportTitle", "Birth Day Pie Report");



Connection con1 = DriverManager.getConnection("jdbc:postgresql://localhost:5432/peopleWARE","postgres","postgres");

byte[] bytes = JasperRunManager.runReportToPdf( jasperReport, parameters, con1);



ServletOutputStream ouputStream = response.getOutputStream();

ouputStream.write(bytes, 0, bytes.length);




Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...