Jump to content
We've recently updated our Privacy Statement, available here ×

toltsch

Members
  • Posts

    15
  • Joined

  • Last visited

toltsch's Achievements

Apprentice

Apprentice (3/14)

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

Recent Badges

0

Reputation

  1. Hi Teodor, Have you added the ability ignore the page width when exporting to HTML. I saw that this reply was from 1 year ago. One of the developers at my company is having this issue. The PDF looks great. but the html export only spans 50% of the browser in internet explorer 7.x Regards, Tim
  2. What release of JasperReport will this be part of?:)
  3. From time to time I'm getting this exception thrown. When I run the report again I do get my 3D pie charts displayed. [12/18/06 14:39:03:374 EST] 0000005b ServletWrappe E SRVE0014E: Uncaught service() exception root cause ImageServlet: net.sf.jasperreports.engine.fill.JRTemplatePrintRectangle [12/18/06 14:39:03:374 EST] 0000005b WebApp E SRVE0026E: [servlet Error]-[imageServlet]: java.lang.ClassCastException: net.sf.jasperreports.engine.fill.JRTemplatePrintRectangle at net.sf.jasperreports.engine.export.JRHtmlExporter.getImage(JRHtmlExporter.java:574) at net.sf.jasperreports.engine.export.JRHtmlExporter.getImage(JRHtmlExporter.java:556) at net.sf.jasperreports.j2ee.servlets.ImageServlet.service(ImageServlet.java:100) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1212) at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1173) at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:69) at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:626) at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:80) at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1657) at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:77) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:421) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:367) at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:94) at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java:548) at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java:601) at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java:934) at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java:1021) at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1332)
  4. It was the brower cache which caused this issue. I had to add a unique parameter to the ImageServlet. I added a parameter with the current date and time. Setting the response header of META data in the html output did not help expire the cache, this is why I added the parameter.
  5. In iReport you would select Data from the menu then Connections / Datasources. Then press New Then drop down the list and select XML file datasource. In code you do the following to call it: JRXmlDataSource jrxmlds = new JRXmlDataSource(xmlFileName,recordPath); print = JasperFillManager.fillReport( "yourreport.jasper", hm, jrxmlds);
  6. Hello, This is more information on another post that I've made. I've found that when you use the net.sf.jasperreports.j2ee.servlets.ImageServlet to Dynamically display chart images it works the first time. I'm using Jasper Reports 1.2.8 (the latest) When you run the same report with different data you get the wrong image. It displays the image from the first run. It seems to never want to display the image from the current run, only the first. When I set the code to write to a directory it works perfectly, but this method is not desired since I have to store the image. Has anyone come across this and this? Code to use ImageServlet: JRHtmlExporter exporter = new JRHtmlExporter(); HashMap imagesMap = new HashMap(); request.getSession().setAttribute("IMAGES_MAP", imagesMap); request.getSession().setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, print); String serverName = request.getServerName(); String serverPort = String.valueOf(request.getServerPort()); if (serverPort != null && serverPort.trim().length() > 0) serverName = serverName + ":" + serverPort + "/"; String servletPath = "jenasys/servlet/"; exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap); exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, request.getScheme()+"://"+serverName+servletPath+"net.sf.jasperreports.j2ee.servlets.ImageServlet?image="); exporter.setParameter(JRHtmlExporterParameter.HTML_HEADER,"<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/></head><body>"); exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, Boolean.FALSE); exporter.setParameter(JRExporterParameter.JASPER_PRINT, print); exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, out); exporter.exportReport();
  7. Hello, I'm having an issue with net.sf.jasperreports.j2ee.servlets.ImageServlet caching images from prior runs of a report with 3D pie charts. I'm using the HtmlExporter to output the report. I'm seeing the same image tag used in previous runs which incorrectly serves up the wrong image. I have a calendar control which runs the Jasper report when you click on a date. I'm seeing this line used in other report runs and when I see this happening it displays the wrong image: <img src="http://pc-2ua62618sz:9080/jenasys/servlet/net.sf.jasperreports.j2ee.servlets.ImageServlet?image=img_0_0_2" border="0" style="height: 170px" usemap="#map_0_0_2" alt=""/> Here is the code used to output the report: public static void renderForm(HttpServletRequest request, HttpServletResponse response, ServletContext context, Object[] objParms) throws Exception { JasperPrint print = null; String inputType = null; String reportFileName = null; String recordPath = null; Document xmlDocument = null; Connection jdbcConnection = null; response.setContentType("text/html"); PrintWriter out = response.getWriter(); try { inputType = ((String) objParms[0]).trim(); reportFileName = ((String) objParms[1]).trim(); xmlDocument = (Document) objParms[2]; HashMap formParms = (HashMap) objParms[3]; long start = System.currentTimeMillis(); java.text.SimpleDateFormat format = new java.text.SimpleDateFormat("ss.SSS"); reportFileName = FormTypeMappingCache.getInstance().getMapping(reportFileName,formParms); formParms.put("JASPER_FILE_PATH",JASPER_REPORTS_FOLDER); if (inputType.equalsIgnoreCase("xml")) { recordPath = RecordPathMappingCache.getInstance().getMapping(reportFileName); CWXmlDataSource jrxmlds = new CWXmlDataSource(xmlDocument,recordPath); long start2 = System.currentTimeMillis(); print = JasperFillManager.fillReport( JASPER_REPORTS_FOLDER+reportFileName+".jasper", formParms, jrxmlds); long elapsedTimeMillis = System.currentTimeMillis()-start2; System.out.println("==> Time spent filling form with data was " + format.format(new Date(elapsedTimeMillis)) + " seconds"); } else if (inputType.equalsIgnoreCase("db")) { jdbcConnection = connectDS(); long start2 = System.currentTimeMillis(); print = JasperFillManager.fillReport( JASPER_REPORTS_FOLDER+reportFileName+".jasper", formParms, jdbcConnection); long elapsedTimeMillis = System.currentTimeMillis()-start2; System.out.println("==> Time spent filling form with data was " + format.format(new Date(elapsedTimeMillis)) + " seconds"); } JRHtmlExporter exporter = new JRHtmlExporter(); HashMap imagesMap = new HashMap(); request.getSession().setAttribute("IMAGES_MAP", imagesMap); request.getSession().setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, print); exporter.setParameter(JRHtmlExporterParameter.HTML_HEADER,"<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/></head><body>"); exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, Boolean.FALSE); exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap); String serverName = request.getServerName(); String serverPort = String.valueOf(request.getServerPort()); if (serverPort != null && serverPort.trim().length() > 0) serverName = serverName + ":" + serverPort + "/"; String servletPath = "jenasys/servlet/"; exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, request.getScheme()+"://"+serverName+servletPath+"net.sf.jasperreports.j2ee.servlets.ImageServlet?image="); //exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, request.getScheme()+"://"+CDCProperties.getWebserverName()+CDCProperties.getAbsServletPath()+"net.sf.jasperreports.j2ee.servlets.ImageServlet?image="); exporter.setParameter(JRExporterParameter.JASPER_PRINT, print); exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, out); exporter.exportReport(); } catch (JRException e) { out.println("<html>"); out.println("<head>"); out.println("<title>JasperReports Error</title>"); //out.println("<link rel="stylesheet" type="text/css" href="../stylesheet.css" title="Style">"); out.println("</head>"); out.println("<body bgcolor="white">"); out.println("<span class="bnew">JasperReports encountered this error :</span>"); out.println("<pre>"); e.printStackTrace(out); out.println("</pre>"); out.println("</body>"); out.println("</html>"); throw e; } catch (Exception e) { e.printStackTrace(); throw e; } catch (Throwable te) { te.printStackTrace(); } finally { if (jdbcConnection != null) jdbcConnection.close(); } } Has anyone seen this before? I've attached a screen shot of my report. size=400]http://www.jasperforge.org/components/com_joomlaboard/uploaded/images/ImageServletBug.GIF Post edited by: toltsch, at: 2006/12/14 21:12 Post edited by: toltsch, at: 2006/12/14 21:17 Post edited by: toltsch, at: 2006/12/14 21:31
  8. I'm using iReport 1.2.7 and have a report with a 3D Pie Chart. I'm using a database query to supply the data for the report. The problem that I'm having is that the query only returns one row and the columns in the row returned contain the information for the pie chart slices. It appears that the key, value and label expressions can only have a single Field or variable entered. My field data for example would be number_orders_open = 10 number_orders_held = 30 number_orders_suspended = 60 I was hoping that an array or some sort of object list could be used for each of the key, value and label expressions. Can this sort of thing be done? I've purchased the iReport documentation and it does not show any examples of doing this. Thanks in advance for any help you can give me. Regards, Tim
  9. I got it to work! I had to change the from exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "image?image="); to exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, " http://localhost:9080/CWCollabAppWeb/servlet/net.sf.jasperreports.j2ee.servlets.ImageServlet?image=");
  10. I'm not sure about what you mean by your reply. Should I change exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "image?image="); to exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "/servlet/image?image="); My web app is named CWCollaborateAppWeb. The URL from the browser of the outputted report is : http://localhost:9080/CWCollaborateAppWeb/servlet/com.cwi.cdc.vendor.packslip.PackSlipServlet?action=packingslipform.jsp&divid=555&batchid=517&count=1
  11. Sorry for reposting this issue, but I'm really stuck. I'm using the JRHtmlExporter to create an html report. The report displays in the browser but the images are not displayed. The image tag looks like this in the html: img src="image?image=img_0_0_2" When I use the isLazy attribute the image src is empty img src="" I'm using the java.net.URL in the report. When I use the ireport tool and test using this URL it works: http://localhost:9080/CWCollaborateAppWeb/cdc/images/cwilogo.jpg My code looks like this: JRHtmlExporter exporter = new JRHtmlExporter(); HashMap imagesMap = new HashMap(); request.getSession().setAttribute("IMAGES_MAP", imagesMap); request.getSession().setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, print); exporter.setParameter(JRHtmlExporterParameter.HTML_HEADER,"<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/></head><body>"); exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, Boolean.FALSE); exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap); exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "image?image="); exporter.setParameter(JRExporterParameter.JASPER_PRINT, print); exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, out); exporter.exportReport(); I also added these lines to my web.xml file: <servlet> <servlet-name>ImageServlet</servlet-name> <servlet-class>net.sf.jasperreports.j2ee.servlets.ImageServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>ImageServlet</servlet-name> <url-pattern>/servlet/image</url-pattern> </servlet-mapping>
  12. I'm using the JRHtmlExporter to create an html report. The report displays in the browser but the images are not displayed. The image tag looks like this in the html: img src="image?image=img_0_0_2" When I use the isLazy attribute the image src is empty img src="" I'm using the java.net.URL in the report. When I use the ireport tool and test using this URL it works: http://localhost:9080/CWCollaborateAppWeb/cdc/images/cwilogo.jpg My code looks like this: JRHtmlExporter exporter = new JRHtmlExporter(); HashMap imagesMap = new HashMap(); request.getSession().setAttribute("IMAGES_MAP", imagesMap); request.getSession().setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, print); exporter.setParameter(JRHtmlExporterParameter.HTML_HEADER,"<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/></head><body>"); exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, Boolean.FALSE); exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap); exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "image?image="); exporter.setParameter(JRExporterParameter.JASPER_PRINT, print); exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, out); exporter.exportReport(); I also added these lines to my web.xml file: <servlet> <servlet-name>ImageServlet</servlet-name> <servlet-class>net.sf.jasperreports.j2ee.servlets.ImageServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>ImageServlet</servlet-name> <url-pattern>image</url-pattern> </servlet-mapping> Any ideas what I'm missing? Regards, Tim
  13. Hi All, I think this should be an easy question. But I cannot find how to set the title for an HTML report. I'm using JRHtmlExporter to render the report. My report does not have a title which causes a problem in IE and the report is not displayed. Here is my code: ... inputType = ((String) objParms[0]).trim(); reportFileName = ((String) objParms[1]).trim(); xmlDocument = (Document) objParms[2]; HashMap formParms = (HashMap) objParms[3]; reportFileName = FormTypeMappingCache.getInstance().getMapping(reportFileName,formParms); formParms.put("JASPER_FILE_PATH",JASPER_REPORTS_FOLDER); if (inputType.equalsIgnoreCase("xml")) { recordPath = RecordPathMappingCache.getInstance().getMapping(reportFileName); CWXmlDataSource jrxmlds = new CWXmlDataSource(xmlDocument,recordPath); print = JasperFillManager.fillReport( JASPER_REPORTS_FOLDER+reportFileName+".jasper", formParms, jrxmlds); } JRHtmlExporter exporter = new JRHtmlExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, print); exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, out); exporter.exportReport(); ... Here is my HTML output: <html> <head> <title/> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <style type="text/css"> a {text-decoration: none} </style> </head> <body text="#000000" link="#000000" alink="#000000" vlink="#000000"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr><td width="50%"> </td><td align="center"> <a name="JR_PAGE_ANCHOR_0_1"/> <table style="width: 792px" cellpadding="0" cellspacing="0" border="0" bgcolor="white"> <tr> <td><img src="nullpx" style="width: 37px; height: 1px"/></td> <td><img src="nullpx" style="width: 122px; height: 1px"/></td> <td><img src="nullpx" style="width: 52px; height: 1px"/></td> <td><img src="nullpx" style="width: 581px; height: 1px"/></td> </tr> <tr valign="top"> <td colspan="4"><img src="nullpx" style="width: 792px; height: 25px"/></td> </tr> <tr valign="top"> <td><img src="nullpx" style="width: 37px; height: 16px"/></td> <td><span style="font-family: sansserif; font-size: 10.0px;">PO Number:</span></td> <td colspan="2"><img src="nullpx" style="width: 633px; height: 16px"/></td> </tr> <tr valign="top"> <td colspan="4"><img src="nullpx" style="width: 792px; height: 9px"/></td> </tr> <tr valign="top"> <td><img src="nullpx" style="width: 37px; height: 18px"/></td> <td colspan="2"><span style="font-family: sansserif; font-size: 10.0px;">0001706</span></td> <td><img src="nullpx" style="width: 581px; height: 18px"/></td> </tr> <tr valign="top"> <td colspan="4"><img src="nullpx" style="width: 792px; height: 544px"/></td> </tr> </table> </td><td width="50%"> </td></tr> </table> </body> </html>
  14. I rewrote the JasperReports JRXmlDataSource using Jaxen and I got a 600% increase in performance. Maybe the Jasper Reports team can rewrite their version using Jaxen? Here is the source code for other people struggling with this issue. I'm using Jasper Reports 1.2.2 with Jaxen 1.1 /* * Created on Sep 10, 2006 * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates */ package com.cwi.direct.custom.datasource; import net.sf.jasperreports.engine.JRDataSource; import net.sf.jasperreports.engine.JRException; import net.sf.jasperreports.engine.JRField; import net.sf.jasperreports.engine.util.JRXmlUtils; import java.io.File; import java.util.List; import java.util.ArrayList; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilder; import org.apache.commons.beanutils.ConvertUtils; import org.jaxen.JaxenException; import org.jaxen.XPath; import org.jaxen.dom.*; import org.w3c.dom.Document; /** * @author Tim Oltsch (toltsch@commercialware.com) * @version $Id: CWXmlDataSource.java,v 1.0 2006/09/11 09:00:00 toltsch Exp $ */ public class CWXmlDataSource implements JRDataSource { // the xml document private org.w3c.dom.Document document; // the XPath select expression that gives the nodes to iterate private String selectExpression; // the node list private List nodeList; // the node list length private int nodeListLength; // the current node private Object currentNode; // current node index private int currentNodeIndex = - 1; /** * */ public CWXmlDataSource() { } public CWXmlDataSource(Document document, String selectExpression) throws JRException { this.document = document; this.selectExpression = selectExpression; moveFirst(); } public CWXmlDataSource(String uri, String selectExpression) throws JRException { this(CWXmlDataSource.loadDocumentFromFile(uri), selectExpression); } public void moveFirst() throws JRException { if (document == null) throw new JRException("document cannot be not null"); if (selectExpression == null) throw new JRException("selectExpression cannot be not null"); try { currentNode = null; currentNodeIndex = -1; nodeListLength = 0; nodeList = getXpathNodeList(document, selectExpression); nodeListLength = nodeList.size(); } catch (Exception e) { throw new JRException("XPath selection failed. Expression: " + selectExpression, e); } } /** * */ public boolean next() throws JRException { if(currentNodeIndex == nodeListLength - 1) return false; currentNode = nodeList.get(++ currentNodeIndex); return true; } /** * */ public Object getFieldValue(JRField jrField) throws JRException { if(currentNode == null) return null; String expression = jrField.getDescription(); if (expression == null || expression.length() == 0) return null; Object value = null; Class valueClass = jrField.getValueClass(); if(Object.class != valueClass) { String text = null; try { text = getXpathStringValue(currentNode,expression); } catch (Exception e) { throw new JRException("XPath selection failed. Expression: " + expression, e); } if(text != null) { if(String.class == valueClass) value = text; else value = ConvertUtils.convert(text.trim(), valueClass); } } return value; } protected static Document loadDocumentFromFile(String file) throws JRException { Document doc = null; try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); DocumentBuilder db = dbf.newDocumentBuilder(); doc = db.parse(new File(file)); } catch(Exception e) { throw new JRException("Input file:"+file+ " was not found."); } return doc; } protected List getXpathNodeList(Object doc,String domxpath) throws Exception { try { XPath xpath = new DOMXPath(domxpath); Object ro = xpath.evaluate(doc); if (ro instanceof List) return (List)xpath.evaluate(doc); else { List results = new ArrayList(); results.add(ro); return results; } } catch(JaxenException je) { throw je; } } protected String getXpathStringValue(Object node,String domxpath) throws Exception { try { XPath xpath = new DOMXPath(domxpath); String value = xpath.stringValueOf(node); if (value.length() == 0) return null; else return value; } catch(JaxenException je) { throw je; } } public CWXmlDataSource subDataSource(String selectExpr) throws JRException { // create a new document from the current node Document doc = subDocument(); return new CWXmlDataSource(doc, selectExpr); } public Document subDocument() throws JRException { if(currentNode == null) { throw new JRException("No node available. Iterate or rewind the data source."); } // create a new document from the current node Document doc = JRXmlUtils.createDocument((org.w3c.dom.Node)currentNode); return doc; } public CWXmlDataSource dataSource(String selectExpr) throws JRException { return new CWXmlDataSource(document, selectExpr); } }
  15. Hi Everyone. I'm using the 1.2.2 version of Jasper Reports. I'm seeing performance issues when using the JRXmlDataSource. I have an input file of about 700K and it takes about 2 secs per page to fill the report. The output of the report is sent to PDF (this is fast and appears to have no issues). I've seen post from 2003 on discussing that files of 2MB and over have had slow response times when using the JRXmlDataSource. I've also seen posts back from the JasperReports Dev team that for better response you have to code a the report using a custom DataSource. Is this the only option for better response time for large XML files? Can anyone point me at a good example of implementing a custom XML DataSource? Also, has anyone come up with a new Xml DataSource which others can use? Any help will be greatly appreciated. Thanks, Tim
×
×
  • Create New...