required Birt runtime in web app [message #1228713] |
Tue, 07 January 2014 16:58 |
Eclipse User |
|
|
|
I want to know which jar files are require if you are only want go get the response of the report( i added all the jar in lib folder and size is 51mb)
I am using following code in my servlet and it has some deprecated methods can you provide me the link of similar example in updated version.
import java.io.IOException;
import java.util.HashMap;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.birt.report.engine.api.EngineConstants;
import org.eclipse.birt.report.engine.api.HTMLRenderContext;
import org.eclipse.birt.report.engine.api.HTMLRenderOption;
import org.eclipse.birt.report.engine.api.IReportEngine;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.engine.api.IRunAndRenderTask;
import org.eclipse.birt.report.model.api.ReportDesignHandle;
import com.birttest.util.BirtEngine;
/**
* Servlet implementation class BirtChartServlet
*/
@WebServlet("/charts")
public class BirtChartServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private IReportEngine birtReportEngine = null;
/**
* @see HttpServlet#HttpServlet()
*/
public BirtChartServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setContentType("text/html");
//get report name and launch the engine
String reportName =
req.getParameter("ReportName");
ServletContext sc =
req.getSession().getServletContext();
this.birtReportEngine =
BirtEngine.getBirtEngine(sc);
//setup image directory
HTMLRenderContext renderContext =
new HTMLRenderContext();
renderContext.setBaseImageURL(
req.getContextPath()+"/images");
renderContext.setImageDirectory(
sc.getRealPath("/images"));
HashMap< String, HTMLRenderContext > contextMap
= new HashMap< String, HTMLRenderContext >();
contextMap.put(
EngineConstants.
APPCONTEXT_HTML_RENDER_CONTEXT,
renderContext );
IReportRunnable design;
try
{
//Open report design
design = birtReportEngine.
openReportDesign(
sc.getRealPath(
"WEB-INF/reports") + "\\" + "new_report.rptdesign" );
//create task to run and render report
IRunAndRenderTask task =
birtReportEngine.
createRunAndRenderTask( design );
task.setAppContext( contextMap );
//set output options
HTMLRenderOption options =
new HTMLRenderOption();
options.
setOutputFormat(
HTMLRenderOption.
OUTPUT_FORMAT_HTML);
options.setOutputStream(
resp.getOutputStream());
task.setRenderOption(options);
//run report
task.run();
task.close();
}catch (Exception e){
e.printStackTrace();
throw new ServletException( e );
}
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.02609 seconds