Jump to content
Changes to the Jaspersoft community edition download ×

anybody successful use jasperreport in web?

2005 IR Help

Recommended Posts

By: Adam - zzy740218

anybody successful use jasperreport in web?

2004-08-17 13:01


I would like to know anybody successfully use jasperreport in web application. Now, I am working on it, and I met a lot of problem. I would like some experienced people give me some help. I alread wrote a servlet to use jasperreport. It works fine on my local windows machine. however, on other unix machines, I can't make it work the same.


thanks in advance





By: Richard Barnett - richard_barnett

RE: anybody successful use jasperreport in we

2004-08-17 22:32

We're using JasperReports from a web app, and I"m sure many others are too.


Describe your problems concisely & you'll be more likely to get useful help.





By: Adam - zzy740218

RE: anybody successful use jasperreport in web?

2004-08-18 07:27



Thank you for your reply. I really need some people who successfully use jasperreport in web application to help me out with my current problem.


I created a servlet, which used jasperreport as helper class to create pdf report. It works fine on my developing machine (windows 2000+Jrun4). How ever when I move it to a (linux+jrun4) testing server, it is messing up. When the length of the text content exceed the textfield box length, it can't begin with a new line. it just overlap the first line content again and again.


I use the ShapesReport.jrxml as report template, which is in jasperreports-0.5.3 demo samples. The servlet I wrote is as following:


import java.io.*;

import java.sql.*;

import java.util.*;

import oracle.sql.*;

import oracle.jdbc.driver.*;

import javax.servlet.*;

import javax.servlet.http.*;


import dori.jasper.engine.JasperManager;

import dori.jasper.engine.JRException;

import dori.jasper.engine.JasperReport;

import dori.jasper.engine.JasperPrint;

import dori.jasper.engine.design.JasperDesign;

import dori.jasper.engine.JasperCompileManager;

import dori.jasper.engine.JasperFillManager;

import dori.jasper.engine.JREmptyDataSource;

import dori.jasper.engine.JasperExportManager;


public class ReportTest extends HttpServlet {


public void doGet(HttpServletRequest req, HttpServletResponse res)

throws ServletException , IOException {


Connection con = null;

String river="oracle.jdbc.driver.OracleDriver";

String sURL="DBURL";

String sUsername="username";

String sPassword="password";


String xmlFileName="ShapesReport.jrxml";

String fileNameReturned="mypdf.pdf";


Map myparameters=null;

String appName=null;




con = DriverManager.getConnection (sURL, sUsername, sPassword);

}catch ( Exception e){

throw new ServletException("here 1 !");





//load JasperDesign from XML and compile it into JasperReport

JasperDesign design;

JasperReport report;

try {

design = JasperManager.loadXmlDesign(xmlFileName);

report = JasperManager.compileReport(design);


catch (Exception e) {

throw new ServletException(e+" can not load or compile the report ! Make sure you create a correct report !");



// create PDF from report

byte[] bytes;

try {

bytes = JasperManager.runReportToPdf(report, myparameters, con);


catch (Exception e) {

throw new ServletException("Can't transfer the report into PDF format!");




//send the pdf report back to client


res.setHeader("Content-Disposition", "attachment; filename="" + fileNameReturned + """);


ServletOutputStream ouputStream = res.getOutputStream();

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




try {



catch (SQLException e) {

throw new ServletException("connection still open");












By: Richard Barnett - richard_barnett

RE: anybody successful use jasperreport in we

2004-08-18 23:00

I'm not sure that your source code is useful -- I don't think that application/x-download is the correct content-type to be using, but I doubt this is the cause.


First thing I'd look at would be your fonts -- are you failing to embed some font that's not available on Linux, or specifying report fonts in the wrong way?

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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...