Jump to content
Changes to the Jaspersoft community edition download ×

Jasper Reports with Jdeveloper and Oracle AS


Recommended Posts

By: Ragu - ragunathareddy

Jasper Reports with Jdeveloper and Oracle AS

2006-01-12 14:21

Jasper Reports with Jdeveloper and Oracle AS on Redhat Linux3.0 Enterprise Server

 

Hi,

 

 

 

I have a web-application using JasperReport

 

 

I'm having the same problem with my images in the sense the pdf version

is ok without any problems, but the html version of my report is

displayed without images and bands. The web- application is developed

using Jdeveloper, on Jdeveloper when executed using OC4J it the pdf is

fine but the html is without the images, but when deployed on Oracle

AS running on Redhat Linux3.0 Enetrprise Server nothing works.

Does anyone have a soution for this?

 

 

Thanks and Regards,

 

Ragunatha Reddy Kummetha.

 

 

 

 

 

By: Denny Valliant - xenden

RE: Jasper Reports with Jdeveloper and Oracle

2006-01-12 21:48

In general, it's probably a path problem. Have you looked at the webapp sample? Don't know if it will help you at all but look at how the path is set therin maybe.

 

Basically try explicitly setting the path to the images and see if you get better results.

 

It also depends on how you are getting the image in there. There are several different ways to do so. I've had some luck using a string and putting a URL to the image in there, but YMMV. Depends on your setup/needs etc..

 

HTH a little...

:x

 

 

 

 

By: Ragu - ragunathareddy

RE: Jasper Reports with Jdeveloper and Oracle AS

2006-01-13 11:28

I have developed on the similar lines of the webapp sample and everything works fine when run form the local Jdeveloper except for the image

s not rendering when exported to the HTML format.

 

But Nothing works when deployed on the application server not ven the pdf which works fine when run from Jdeveloper.

 

Does anyone has a fix or solution for this??

 

 

 

 

 

 

 

 

By: Ragu - ragunathareddy

RE: Jasper Reports with Jdeveloper and Oracle AS

2006-01-13 11:32

The Scripplet code for the jsp which returns pdf version of the report is

<%

 

File reportFile = new File(application

.getRealPath("/reports/TestReport.jasper"));

if (!reportFile.exists())

throw new JRRuntimeException(

"File TestReport.jasper not found. The report design must be compiled first.");

 

Map parameters = new HashMap();

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

try {

Class.forName("oracle.jdbc.driver.OracleDriver");

String url = "jdbc:oracle:thin:@172.28.128.81:1521:CJISDEV";

Connection conn = DriverManager.getConnection(url, "rkummetha",

"rkummetha");

 

byte[] bytes = JasperRunManager.runReportToPdf(reportFile

.getPath(), parameters, conn);

 

response.setContentType("application/pdf");

response.setContentLength(bytes.length);

ServletOutputStream ouputStream = response.getOutputStream();

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

ouputStream.flush();

ouputStream.close();

 

conn.close();

} catch (java.lang.Exception ex) {

 

ex.printStackTrace();

}

 

%>

 

 

 

 

 

 

 

By: Ragu - ragunathareddy

RE: Jasper Reports with Jdeveloper and Oracle AS

2006-01-13 11:35

The scripplet code for the jsp which returns report in HTML form Pagewise is

 

<%

 

JasperPrint jasperPrint = (JasperPrint)session.getAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE);

 

if (request.getParameter("reload") != null || jasperPrint == null)

{

File reportFile = new File(application.getRealPath("/reports/TestReport.jasper"));

if (!reportFile.exists())

throw new JRRuntimeException("File TestReport.jasper not found. The report design must be compiled first.");

 

JasperReport jasperReport = (JasperReport)JRLoader.loadObject(reportFile.getPath());

 

Map parameters = new HashMap();

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

try {

Class.forName("oracle.jdbc.driver.OracleDriver");

String url = "jdbc:oracle:thin:@172.28.128.81:1521:CJISDEV";

Connection conn = DriverManager.getConnection(url, "rkummetha",

"rkummetha");

jasperPrint =

JasperFillManager.fillReport(

jasperReport,

parameters,

conn

);

session.setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, jasperPrint);

 

conn.close();

} catch (java.lang.Exception ex) {

 

ex.printStackTrace();

}

 

}

 

JRHtmlExporter exporter = new JRHtmlExporter();

 

int pageIndex = 0;

int lastPageIndex = 0;

if (jasperPrint.getPages() != null)

{

lastPageIndex = jasperPrint.getPages().size() - 1;

}

 

String pageStr = request.getParameter("page");

try

{

pageIndex = Integer.parseInt(pageStr);

}

catch(Exception e)

{

}

 

if (pageIndex < 0)

{

pageIndex = 0;

}

 

if (pageIndex > lastPageIndex)

{

pageIndex = lastPageIndex;

}

 

StringBuffer sbuffer = new StringBuffer();

exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);

exporter.setParameter(JRExporterParameter.OUTPUT_STRING_BUFFER, sbuffer);

//exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, "../servlets/image?image=");

exporter.setParameter(JRExporterParameter.PAGE_INDEX, new Integer(pageIndex));

exporter.setParameter(JRHtmlExporterParameter.HTML_HEADER, "");

exporter.setParameter(JRHtmlExporterParameter.BETWEEN_PAGES_HTML, "");

exporter.setParameter(JRHtmlExporterParameter.HTML_FOOTER, "");

 

exporter.exportReport();

 

%>

 

<html>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

 

<body text="#000000" link="#000000" alink="#000000" vlink="#000000">

<hr size="1" >

<table>

<tr>

<td><a href="HtmlPagination.jsp?reload=true"><img src="../images/reload.GIF"

border="0" height="23"

width="70" alt="Reload" ></a></td>

<%

if (pageIndex > 0)

{

%>

<td><a href="HtmlPagination.jsp?page=0"><img src="../images/first.GIF" border="0" height="23" width="23" alt="First" ></a></td>

<td><a href="HtmlPagination.jsp?page=<%=pageIndex - 1%>"><img src="../images/previous.GIF" border="0" height="23" width="23" alt="Previous"></a></td>

<%

}

else

{

%>

<td><img src="../images/first_grey.GIF" border="0" height="23" width="23" alt="First"></td>

<td><img src="../images/previous_grey.GIF" border="0" height="23" width="23" alt="Previous"></td>

<%

}

 

if (pageIndex < lastPageIndex)

{

%>

<td><a href="HtmlPagination.jsp?page=<%=pageIndex + 1%>"><img src="../images/next.GIF" border="0" height="23" width="23" alt="Next"></a></td>

<td><a href="HtmlPagination.jsp?page=<%=lastPageIndex%>"><img src="../images/last.GIF" border="0" height="23" width="23" alt="Last"></a></td>

<%

}

else

{

%>

<td><img src="../images/next_grey.GIF" border="0" height="23" width="23" alt="Next" ></td>

<td><img src="../images/last_grey.GIF" border="0" height="23" width="23" alt="Last"></td>

<%

}

%>

 

</tr>

</table>

<hr size="1">

 

<p align="center">

<%=sbuffer.toString()%>

</p>

</body>

</html>

 

 

 

 

 

By: Ragu - ragunathareddy

RE: Jasper Reports with Jdeveloper and Oracle AS

2006-01-13 11:31

The scripplet for the jsp which returns HTML version of the Report is

 

<%

 

 

File reportFile = new File(application.getRealPath("/reports/TestReport.jasper"));

if (!reportFile.exists())

throw new JRRuntimeException(

"File TestReport.jasper not found. The report design must be compiled first.");

 

JasperReport jasperReport = (JasperReport) JRLoader.loadObject(reportFile.getPath());

 

Connection conn=null;

Map parameters = new HashMap();

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

try {

Class.forName("oracle.jdbc.driver.OracleDriver");

String url = "jdbc:oracle:thin:@172.28.128.81:1521:CJISDEV";

conn = DriverManager.getConnection(url, "rkummetha",

"rkummetha");

JasperPrint jasperPrint = JasperFillManager.fillReport(

jasperReport, parameters, conn);

 

JRHtmlExporter exporter = new JRHtmlExporter();

 

StringBuffer sbuffer = new StringBuffer();

 

session.setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE,

jasperPrint);

 

exporter.setParameter(JRExporterParameter.JASPER_PRINT,

jasperPrint);

 

exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, out);

 

exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "../servlets/image?image=");

exporter.exportReport();

} catch (java.lang.Exception ex) {

 

ex.printStackTrace();

} finally {

conn.close();

}

 

 

%>

 

 

 

 

 

By: Denny Valliant - xenden

RE: Jasper Reports with Jdeveloper and Oracle

2006-01-13 13:17

You should check out: http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/export/JRHtmlExporterParameter.html

 

As it has all the Html export options. Probably just look through the API and see what options are settable and how. I see options like "images_dir_name" in JRHtmlExporterParameter, maybe explore that one?

 

I haven't had much experience/trouble with images, so sorry so vague.

 

:x

 

-ps usually you want to be sure you omit any real connection information (usernames/passwords, etc.)

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