Jump to content
Changes to the Jaspersoft community edition download ×

big problem of pdf jasperreport output,help!


2005 IR Help

Recommended Posts

By: nkoffee - nkoffee

big problem of pdf jasperreport output,help!

2004-05-18 19:21

when i use jsp to call a servlet method to get jasper

erport and use pdf outputfomat,

but ie just remind me to download file,

not display pdffomat jasperreport directly

how to solve this problem

 

 

 

 

By: Mayur - mayuragrawal

RE: big problem of pdf jasperreport output,help!

2004-05-18 22:19

you can export the report in pDF format with some name and ebmed the file in your JSP using ?<OBject> or <embed> html tag.

THis way it will display the pdf in browser using pdf plug in. If you r using IE, then it can download pdf plugin also. search on net for help in displaying pdf in html, you will get lots of helpful links.

 

 

 

 

 

 

By: nkoffee - nkoffee

RE: big problem of pdf jasperreport output,help!

2004-05-19 00:11

take a look of my code :

 

1 the control jsp file:

 

<%@ page contentType="text/html; charset=GB2312" %>

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

<%@ page import="com.sunyard.ess.util.*"%>

<%

Hashtable hashpara = SfbTools.reqToHashNoUpCase(request);

String todaydate = (new java.text.SimpleDateFormat("yyyyMMdd")).format(new java.util.Date()).toString();

hashpara.put("todaydate",todaydate);

session.putValue("hashpara",hashpara);

String outfomat = request.getParameter("outfomat");

if(outfomat.equals("html")){ %>

<jsp:forward page="/reportservlet/reportengine?outfomat=html"/>

<% }else if(outfomat.equals("pdf")){ %>

<jsp:forward page="/reportservlet/reportengine?outfomat=pdf"/>

<% }else if(outfomat.equals("applet")){ %>

<jsp:forward page="/report/viewer.jsp"/>

<% } %>

 

2 servlet method:

private synchronized void pdfoutput(HttpServletRequest request,

HttpServletResponse response) throws

IOException, ServletException {

 

ServletContext context = this.getServletConfig().getServletContext();

HttpSession session = request.getSession();

Map parameters = (Hashtable)session.getAttribute("hashpara");

String reporturl = (String)parameters.get("reporturl");

File reportFile = new File(context.getRealPath(reporturl));

parameters.put("BaseDir", reportFile.getParentFile());

byte[] bytes = null;

try {

bytes =

JasperRunManager.runReportToPdf(

reportFile.getPath(),

parameters,

conn

);

}

catch (JRException e) {

printWrongCode(response, e);

return;

}

if (bytes != null && bytes.length > 0) {

response.setContentType("application/pdf");

response.setContentLength(bytes.length);

ServletOutputStream ouputStream = response.getOutputStream();

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

ouputStream.flush();

ouputStream.close();

}

else {

System.out.println("Report data is null,Something must be wrong!");

}

 

}

 

 

i use a control.jsp to call a sevletmethod and return pdf report code

how can i use ?<OBject> or <embed> html tag

in this way

 

 

 

 

By: nkoffee - nkoffee

RE: big problem of pdf jasperreport output,help!

2004-05-19 00:33

and many thanks of your answer,

i have get more clear of this problem,

but i can't find someting of display pdf file in ie

using <object><embed> html tag resource

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