Skip to main content



      Home
Home » Archived » BIRT » Image URL in HTML report is wrong
Image URL in HTML report is wrong [message #254064] Fri, 31 August 2007 05:57 Go to next message
Eclipse UserFriend
Originally posted by: dominik.spitzer.web.de

Hi,

I found some posts with a similar problem, but no solution that helped me.
The problem is, that the generated HTML from a report contains image url
like this: "file:/jboss-4.0.3.sp1/server/default/.../images/image.png"
when should look like this: "www.mydomain.com/MyWebApp/images/image.png"
or at least "/MyWebApp/images/image.png".

I'm using code like the following to set up the engine:

class MyServlet extends HttpServlet {
private void doGet(HttpServletRequest req, HttpServletResponse resp) {
resp.setContentType("text/html");
String reportName = req.getParameter("report");
ServletContext sc = req.getSession().getServletContext();

IReportRunnable design;

if (engine == null) {
// create report engine
EngineConfig config = new EngineConfig();
config.setEngineHome("");
config.setLogConfig(null, Level.WARNING);

try {
Platform.startup(config);
IReportEngineFactory factory = (IReportEngineFactory)
Platform.createFactoryObject(
IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);

engine = factory.createReportEngine(config);
engine.changeLogLevel(Level.WARNING);

//Open report design
design = viewer.openReportDesign(sc.getRealPath("/reports/"
+ reportName));

//set output options
HTMLRenderOption opt = new HTMLRenderOption();
opt.setOutputFormat(HTMLRenderOption.OUTPUT_FORMAT_HTML);
opt.setOutputStream(resp.getOutputStream());
opt.setBaseImageURL(req.getContextPath() + "/images");
opt.setImageDirectory(sc.getRealPath("/images"));

//create task to run and render report
IRunAndRenderTask task =
engine.createRunAndRenderTask(report);
task.setRenderOption(option);
task.run();
task.close();
} catch (BirtException e) {
System.out.println("Platform startup failed");
e.printStackTrace();
}
}
}

Thanks for your help!

Dominik
Re: Image URL in HTML report is wrong [message #254068 is a reply to message #254064] Fri, 31 August 2007 05:59 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dominik.spitzer.web.de

Sorry, I forgot. I'm using Eclipse 3.3.0 and BIRT 2.2.0 on JBoss 4.0.3.SP1.

Dominik Spitzer schrieb:
> Hi,
>
> I found some posts with a similar problem, but no solution that helped me.
> The problem is, that the generated HTML from a report contains image url
> like this: "file:/jboss-4.0.3.sp1/server/default/.../images/image.png"
> when should look like this: "www.mydomain.com/MyWebApp/images/image.png"
> or at least "/MyWebApp/images/image.png".
>
> I'm using code like the following to set up the engine:
>
> class MyServlet extends HttpServlet {
> private void doGet(HttpServletRequest req, HttpServletResponse resp) {
> resp.setContentType("text/html");
> String reportName = req.getParameter("report");
> ServletContext sc = req.getSession().getServletContext();
>
> IReportRunnable design;
>
> if (engine == null) {
> // create report engine
> EngineConfig config = new EngineConfig();
> config.setEngineHome("");
> config.setLogConfig(null, Level.WARNING);
>
> try {
> Platform.startup(config);
> IReportEngineFactory factory = (IReportEngineFactory)
> Platform.createFactoryObject(
> IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
>
> engine = factory.createReportEngine(config);
> engine.changeLogLevel(Level.WARNING);
>
> //Open report design
> design = viewer.openReportDesign(sc.getRealPath("/reports/"
> + reportName));
>
> //set output options
> HTMLRenderOption opt = new HTMLRenderOption();
> opt.setOutputFormat(HTMLRenderOption.OUTPUT_FORMAT_HTML);
> opt.setOutputStream(resp.getOutputStream());
> opt.setBaseImageURL(req.getContextPath() + "/images");
> opt.setImageDirectory(sc.getRealPath("/images"));
>
> //create task to run and render report
> IRunAndRenderTask task =
> engine.createRunAndRenderTask(report);
> task.setRenderOption(option);
> task.run();
> task.close();
> } catch (BirtException e) {
> System.out.println("Platform startup failed");
> e.printStackTrace();
> }
> }
> }
>
> Thanks for your help!
>
> Dominik
Re: Image URL in HTML report is wrong [message #254076 is a reply to message #254064] Fri, 31 August 2007 07:03 Go to previous message
Eclipse UserFriend
Originally posted by: dominik.spitzer.web.de

Ok, I fixed this myself. I had to use a HTMLServerImageHandler. Sorry
for spaming the list! ;-)

Greetings, Dominik

Dominik Spitzer schrieb:
> Hi,
>
> I found some posts with a similar problem, but no solution that helped me.
> The problem is, that the generated HTML from a report contains image url
> like this: "file:/jboss-4.0.3.sp1/server/default/.../images/image.png"
> when should look like this: "www.mydomain.com/MyWebApp/images/image.png"
> or at least "/MyWebApp/images/image.png".
>
> I'm using code like the following to set up the engine:
>
> class MyServlet extends HttpServlet {
> private void doGet(HttpServletRequest req, HttpServletResponse resp) {
> resp.setContentType("text/html");
> String reportName = req.getParameter("report");
> ServletContext sc = req.getSession().getServletContext();
>
> IReportRunnable design;
>
> if (engine == null) {
> // create report engine
> EngineConfig config = new EngineConfig();
> config.setEngineHome("");
> config.setLogConfig(null, Level.WARNING);
>
> try {
> Platform.startup(config);
> IReportEngineFactory factory = (IReportEngineFactory)
> Platform.createFactoryObject(
> IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
>
> engine = factory.createReportEngine(config);
> engine.changeLogLevel(Level.WARNING);
>
> //Open report design
> design = viewer.openReportDesign(sc.getRealPath("/reports/"
> + reportName));
>
> //set output options
> HTMLRenderOption opt = new HTMLRenderOption();
> opt.setOutputFormat(HTMLRenderOption.OUTPUT_FORMAT_HTML);
> opt.setOutputStream(resp.getOutputStream());
> opt.setBaseImageURL(req.getContextPath() + "/images");
> opt.setImageDirectory(sc.getRealPath("/images"));
>
> //create task to run and render report
> IRunAndRenderTask task =
> engine.createRunAndRenderTask(report);
> task.setRenderOption(option);
> task.run();
> task.close();
> } catch (BirtException e) {
> System.out.println("Platform startup failed");
> e.printStackTrace();
> }
> }
> }
>
> Thanks for your help!
>
> Dominik
Previous Topic:birt 2.2 fails to locate java classes in importPackage script statements
Next Topic:Table Of Contents as a report item
Goto Forum:
  


Current Time: Tue May 13 10:04:49 EDT 2025

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

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

Back to the top