Jump to content
Changes to the Jaspersoft community edition download ×

LastPage Footer - Blank Space At other Pages


2005 IR Help

Recommended Posts

By: Saravanan - sarmal

LastPage Footer - Blank Space At other Pages

2004-06-14 01:24

Dear Friends

 

I am Using Jasper Reports in my Application

 

I have Write a Scriptlet to Show the PageFooter in the Last Page .

 

It is executing well , But I got Blank Space of the Page Footer in Each Page & At the Last Page I got Datas at the Last Page - Page Footer .

 

How do I avoide the Page Footer Blank Space at all the n-1 Pages ( i.e Except Last page )

 

Is it Possible to Resize the Page Footer - Size in Scriptlet So that its Size at Other than Last Page Should be Zero.

 

Is there any Other Solution for it

 

Regards

Sarmal

 

 

 

By: Chr|s - ck_buchanan

Begineer Help

2004-06-12 13:25

Hi there I am brand new to using iReports, I'm actually doing research on how to use it for my java development course in college. I have figured out how to use iReports, and have designed a report that accepts parameters. No i need to know how to make a java class to get a parameter from the url (request.getParameter(..)) and then compile the report and display in html format. If anyone can help me out here, or forward me to somewhere I can figure this out it would be greatly appreciated.

 

Chris

 

 

 

 

By: Chr|s - ck_buchanan

RE: Begineer Help

2004-06-13 14:44

I made a java class using that implements the struts framework. I call the action class and can successfully pass in parameters and print to a pdf file. What I really want to do though is print to html. Right now I am using JasperManager.printReportToPdfFile, is there a way i can print to an html file. If there is that the file i print to can be my success page for struts.

 

 

Here is my class but all i really need to know how to do is print to an html file.

 

public final class BuildReportAction extends Action

{

public ActionForward execute( ActionMapping mapping,

ActionForm form,

HttpServletRequest request,

HttpServletResponse response)throws IOException

{

ActionForward nextPage = null;

DBConnectionManager conMan = null;

Connection dbConn = null;

PrintWriter out = response.getWriter();

 

try{

conMan = DBConnectionManager.getInstance();

dbConn = conMan.getConnection("csn");

dbConn.setAutoCommit(false);

 

 

Map parameters = new HashMap();

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

parameters.put("id", param); // this is the name of the parameter

 

 

JasperPrint jrPrint = JasperManager.fillReport("C:\iReport\text.jasper", parameters, dbConn);

JasperManager.printReportToPdfFile(jrPrint, "C:\tomcat5.0\webapps\csn\BasicReport.pdf");

 

 

conMan.freeConnection("csn",dbConn);

nextPage = mapping.findForward("success");

}

 

 

 

 

By: Chr|s - ck_buchanan

RE: Begineer Help

2004-06-13 16:14

Never mind i figured it out

 

 

 

 

By: Chr|s - ck_buchanan

RE: Begineer Help

2004-06-13 16:31

I thought I'd put up my example which is a very simple example of how to display your compiled jasper report which I made in iReports. This produces a dynamic report, which connects to a mysql database with parameters being passed into it. Hope this helps someone new to iReports and/or jasper reports looking for a point in the right direction.

 

 

/*Created by Chris Buchanan (chris@redsphere.ca)

*for IST 410 @ The Northern Alberta Institute of Technology

*This action class requires parameters to be passed into it

*to compile an display a report. Commented code is available below

*to display reports that do not require parameters. This

*class will build a pdf, and html version of your report.

*This is a very basic example and only does what it says it does.

*

*Enjoy

*

*Creation Date = June 13, 2004

*/

 

package crud;

 

import javax.servlet.http.*;

import org.apache.struts.action.*;

import java.sql.*;

import utilities.*;

import java.io.*;

import java.util.*;

 

import java.io.IOException;

import dori.jasper.engine.*;

import dori.jasper.engine.export.*;

/**

* categoryActionAdd is designed to add

* a single record to table category

*/

public final class BuildReportAction extends Action

{

public ActionForward execute( ActionMapping mapping,

ActionForm form,

HttpServletRequest request,

HttpServletResponse response)throws IOException

{

ActionForward nextPage = null;

DBConnectionManager conMan = null;

Connection dbConn = null;

 

 

try{

// This instanstiates an instance of mysql drivers to connect to my database

// which is named db43, you would replace that to match you database connection.

 

Class.forName("org.gjt.mm.mysql.Driver");

Connection con = DriverManager.getConnection("jdbc:mysql://localhost/db43");

 

// Parameters are stored in a hash map as strings

// regardless of their datatype(string, int, double, etc..)

 

Map parameters = new HashMap();

String param1 = request.getParameter("product_id");

parameters.put("id", param1); // this is the name of the parameter

 

// To produce a report without parameters comment the above 3 lines out,

// comment the 1st JasperPrint line and uncomment the 2nd

 

 

// This takes the jasper file and compiles it into jrPrint using the dbConn connection

// and the hash map you declared called parameters. The 2nd instance which is commented out

// is so you can compile without parameters. Follow instructions above to do complete this.

JasperPrint jrPrint = JasperManager.fillReport("C:\iReport\text.jasper", parameters, dbConn);

//JasperPrint jrPrint = JasperManager.fillReport("C:\iReport\text.jasper", null, dbConn);

 

 

// printReportToPdfFile is used so that a pdf version is also available, you may wish to link

// to the pdf to save a copy.

JasperManager.printReportToPdfFile(jrPrint, "C:\tomcat5.0\webapps\csn\BasicReport.pdf");

 

 

// The JasperExportManager is responsible for exporting reports to various file formats

JasperExportManager jManager = new JasperExportManager();

 

// In this particular instance we will compile to an HTML file

// the first parameter is the compiled report which was saved

// in jrPrint, and the second is the output directory.

// My output directory is named the same as my success page located

// in struts-config.xml

jManager.exportReportToHtmlFile(jrPrint, "C:\tomcat5.0\webapps\csn\BasicReport.htm");

 

 

// Because I used struts I have action mapping setup already which

// when success is called it loads my success page, which happens

// to be named the same as my output file above. To modify

// this so you don't require struts you could do a redirect or

// something along those lines here.

nextPage = mapping.findForward("success");

}

 

// The following catches simply catch the a possible sql error, class not found error,

// and a possible jasper runtime error that could occur. I am not

// sure if these work in struts but they should.

 

catch ( java.lang.ClassNotFoundException e ) {

System.out.println("MySQL JDBC Driver not found ... ");

}

catch ( java.sql.SQLException sql ) {

PrintWriter out = response.getWriter();

System.out.println("Connection couldn't be established to ");

 

}

catch ( dori.jasper.engine.JRException jr) {

PrintWriter out = response.getWriter();

out.println("<html>");

out.println("<head>");

out.println("<title>JasperReports - Web Application Sample</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>");

out.println("</pre>");

out.println("</body>");

out.println("</html>");

jr.printStackTrace(out);

}

return nextPage;

}

}

 

 

 

 

 

By: GTI - gtigti

RE: Begineer Help (Printing)

2004-06-14 00:53

Anyone have example on printing ?

I'm using JasperPrintManager.printReport(jasperPrint, true) to print but the printer DialogBox is displayed in the server machine (WebSphere Application Server) and not on the client machine ....

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