Results 1 to 2 of 2

Thread: Save JasperReport Generated PDF To File in Server

  1. #1

    Question StackOverflowError when saving Jjasper PDF To File with Tomcat 3

    Hello,

    I'm trying to save the reports (actually letters sent to customers) generated with jasperReports to a file in the server. That is, after the user clicks on the button 'Generate Letters', the pdf is sent back to the browser AND i also want to save a copy. Here's my code so far, in the handleRequestInternal method of a subclassed AbstractForm:
    Code:
    String ids = request.getParameter(Constants.DATAGRID_SELECTION_PARAMETER);
    		HashMap modelo = new HashMap();
    		modelo.put("ids","(" + ids + ")");
            
            DataSource ds = (DataSource)getApplicationContext().getBean("dataSource");
            JasperReport jr = (JasperReport)JRLoader.loadObject(getServletContext().getRealPath("/") + "/reports/cartaAlta.jasper"); 
            JasperPrint print = JasperFillManager.fillReport(jr, modelo, ds.getConnection());
            JasperExportManager.exportReportToPdfFile(print,"cartas.pdf");
           
            return new ModelAndView("cartaAltaView",modelo);
    With this code, i get this stack trace:

    Code:
    [ERROR] DispatcherServlet - -Could not complete request <org.springframework.web.util.NestedServletE
    xception: Handler processing failed; nested exception is java.lang.StackOverflowError: null>org.spri
    ngframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lan
    g.StackOverflowError: null
    java.lang.StackOverflowError
            at java.lang.StringBuffer.<init>(StringBuffer.java:126)
            at java.util.Locale.toString(Locale.java:466)
            at java.lang.String.valueOf(String.java:2013)
            at java.lang.StringBuffer.append(StringBuffer.java:365)
            at java.util.AbstractMap.toString(AbstractMap.java:562)
            at java.lang.String.valueOf(String.java:2013)
            at java.lang.StringBuffer.append(StringBuffer.java:365)
            at java.util.AbstractMap.toString(AbstractMap.java:562)
            at java.lang.String.valueOf(String.java:2013)
            at java.lang.StringBuffer.append(StringBuffer.java:365)
            at java.util.AbstractMap.toString(AbstractMap.java:562)
            at java.lang.String.valueOf(String.java:2013)
            at java.lang.StringBuffer.append(StringBuffer.java:365)
            at java.util.AbstractMap.toString(AbstractMap.java:562)
    ...
    (and so on and on)
    And this is the view definition:
    Code:
        <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            <property name="driverClassName"><value>oracle.jdbc.driver.OracleDriver</value></property>
         	<property name="url"><value>jdbc:oracle:thin:@99.99.99.99:1521:BDDESBCN</value></property>
            <property name="username"><value>****</value></property>
            <property name="password"><value>****</value></property>
        </bean>
    (of course the ip is ficticious)
    
        <bean id="cartaAltaView" class="org.springframework.web.servlet.view.jasperreports.JasperReportsPdfView">
            <property name="url" value="/reports/cartaAlta.jasper"/>
            <property name="jdbcDataSource" ref="dataSource"/>
            <property name="headers">
            	<props>
            		<prop key="Content-Disposition">attachment; filename=cartasBaja.pdf</prop>
            		<prop key="Content-type">application/pdf</prop>
            	</props>
            </property>
        </bean>

    I don't know what i'm doing wrong. I know the report file is OK because if i don't render it by hand, it returns gracefully to the browser and opens in acrobat.
    I'm using Spring 1.2.7, JasperReports 1.2.

    <update>
    I'm using Tomcat 3.3 (it's a requirement od the application). I've tried in Tomcat 4 and it works fine!! Now I'm even more puzzled...



    Any hint? Thanks a lot!!!
    Last edited by npintos; Nov 7th, 2006 at 05:56 AM. Reason: missing code

  2. #2

    Default

    Hi,

    Me too having the same agenda to save the copy of report in server side and serve it to client.

    I'm doing this for mailing purpose. That is when clicking the Mail Report Button in client side the pdf file should be sent as attachment in the mail..

    Using the modal and view controller.

    I don't know how to save the file in modal and view controller.

    Please advice me...

    Thanks in advance...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •