Skip to main content



      Home
Home » Archived » BIRT » What am I doing wrong
What am I doing wrong [message #103170] Mon, 02 January 2006 00:24 Go to next message
Eclipse UserFriend
I use outputstream in servlet program. My Program is given below. After
executing this program I get a blank page.



package report;

import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;

import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.EngineException;
import org.eclipse.birt.report.engine.api.HTMLCompleteImageHandler;
import org.eclipse.birt.report.engine.api.HTMLEmitterConfig;
import org.eclipse.birt.report.engine.api.HTMLRenderOption;
import org.eclipse.birt.report.engine.api.IGetParameterDefinitionTa sk;
import org.eclipse.birt.report.engine.api.IParameterDefnBase;
import org.eclipse.birt.report.engine.api.IParameterGroupDefn;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.engine.api.IRunAndRenderTask;
import org.eclipse.birt.report.engine.api.IScalarParameterDefn;
import org.eclipse.birt.report.engine.api.ReportEngine;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
import java.util.Calendar;
import java.util.Vector;
import java.text.SimpleDateFormat;
import org.w3c.dom.*;
import org.apache.ecs.html.*;
import org.apache.ecs.HtmlColor;
import MyGrid.JSPGridGenerator.*;

public class UserRegReport extends HttpServlet
{

String reportName = null;

String format = "p";
boolean showInfo = false;


private static final String CONTENT_TYPE = "text/html";
public void init(ServletConfig config) throws ServletException
{
super.init(config);
}

public static void run( String name, HashMap params,
String format, boolean showInfo )
{
// The EngineConfig is used to set up engine-wide configuration
// information.

EngineConfig config = new EngineConfig( );

// The Engine home is the location of the BIRT engine runtime.
// M3 Note: Use the report engine installed as part of the BIRT web app
// used to preview reports. Alter this path to the location of your
// Eclipse installation.

config.setEngineHome( "..\\webapps\\learnity" );

// HTML reports can have embedded images or charts. Set up the
configuration
// required to write these into a directory in the output directory.
// The HTMLCompleteImageHandler is one provided by BIRT for this purpose.
// Your application can create a customized version to provide
alternative
// ways to handle images.

HTMLEmitterConfig hc = new HTMLEmitterConfig( );
HTMLCompleteImageHandler imageHandler = new HTMLCompleteImageHandler( );
hc.setImageHandler( imageHandler );
config.setEmitterConfiguration( HTMLRenderOption.OUTPUT_FORMAT_HTML, hc
);

// Create the report engine itself. This engine can be used to run
// multiple reports.

ReportEngine engine = new ReportEngine( config );

// Open the report design.

IReportRunnable report = null;
try
{
report = engine.openReportDesign( name );
}
catch ( EngineException e )
{
System.err.println( "Report " + name + " not found!\n" );
engine.destroy( );
return;
}

if ( format != null )
{

// Hparams.put(params,params);

IRunAndRenderTask task = engine.createRunAndRenderTask( report );
HTMLRenderOption options = new HTMLRenderOption( );
options.setOutputFormat( format );
//String output = name.replaceFirst( ".rptdesign", "." + format );
options.setOutputStream( ostream );
task.setRenderOption( options );
task.setParameterValues( params );

// Run the report.

try
{
task.run( );
task = null;
}
catch ( EngineException e1 )
{
System.err.println( "Report " + name + " run failed.\n" );
System.err.println( e1.toString( ) );
}
}

engine.destroy( );
}

public void doPost(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException
{
response.setContentType("text/html");
response.setHeader("Pragma","no-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires",0);

PrintWriter out = response.getWriter();
HttpSession mysession=request.getSession(true);

format = HTMLRenderOption.OUTPUT_FORMAT_PDF;
reportName = "../webapps/learnity/report/user_reg.rptdesign";
HashMap params = new HashMap();

run( reportName, params, format, showInfo );
Html html = new Html();
Head head = new Head();
Body body = new Body();

head.addElement(new Head()
.addElement(new Title("Report"))
);

response.sendRedirect("../report/user_reg.pdf");
//response.sendRedirect("../run?__report=report/category_report_piechart.rptdesign ");
html.addElement(head);
html.addElement(body);
out.print(html.toString());
}

public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException
{
doPost(request,response);
}
}


What am I doing wrong
Re: What am I doing wrong [message #103378 is a reply to message #103170] Tue, 03 January 2006 03:15 Go to previous message
Eclipse UserFriend
try this one.
options.setOutputStream(response.getOutputStream());
Previous Topic:how do i link TreeItems of Tree to ProperSheetView??
Next Topic:Chart is not working at the time of parameter passing
Goto Forum:
  


Current Time: Fri Jul 18 22:31:33 EDT 2025

Powered by FUDForum. Page generated in 0.03327 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top