Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Servlet doGet is called more than one time when Birt Report is integrated
sgeovar
Hi
I have created a BIRT report and this report is called from the servlet.
It has been deployed in weblogic. Report's datasource open method instantiates a java class and get the data as an ArrayList.
When i deploy and test it, this servlet's doGet method is called 2 or 3 times.
Sometimes it is called 5 times for a single request. Please help me to resolve this issue.
servlet doGet method code follows
resp.setContentType("application/pdf");
resp.setHeader("Content-Disposition",
"inline; filename=test.pdf");
PDFRenderContext renderContext = new PDFRenderContext();
contextMap.put(EngineConstants.APPCONTEXT_PDF_RENDER_CONTEXT,
renderContext);
task.setAppContext(contextMap);
PDFRenderOption options = new PDFRenderOption();
options.setOutputFormat(HTMLRenderOption.OUTPUT_FORMAT_PDF);
options.setOutputStream(resp.getOutputStream());
task.setRenderOption(options);
}
task.addScriptableJavaObject("begin", begin);
task.addScriptableJavaObject("end", end);
// run report
task.run();
task.close();
Find more posts tagged with
Comments
mwilliams
You only call the class in the open method of the dataSet? What version of BIRT are you using? Do you have the dataSet attached to more than one report item? How is your report set up?
sgeovar
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="69525" data-time="1287510426" data-date="19 October 2010 - 10:47 AM"><p>
You only call the class in the open method of the dataSet? What version of BIRT are you using? Do you have the dataSet attached to more than one report item? How is your report set up?<br /></p></blockquote>
<br />
<br />
Hi mwillams<br />
<br />
Thank you very much for your reply. Sorry for the delayed response. <br />
I'm using the version 2.5.2. I call the class in the open method of the dataset.<br />
Dataset is not attached to more than one report. <br />
<br />
Report is set up as follows. <br />
<br />
This is an webapp application deployed in weblogic.<br />
Http request invokes the servlet which calls the Birt report in the following way. I'm running a PDF report.<br />
<br />
resp.setContentType("application/pdf");<br />
resp.setHeader("Content-Disposition","inline; filename=test.pdf");<br />
PDFRenderContext renderContext = new PDFRenderContext();<br />
contextMap.put(EngineConstants.APPCONTEXT_PDF_RENDER_CONTEXT,renderContext);<br />
task.setAppContext(contextMap);<br />
<br />
<br />
// set output options<br />
PDFRenderOption options = new PDFRenderOption();<br />
options.setOutputFormat(HTMLRenderOption.OUTPUT_FORMAT_PDF);<br />
options.setOutputStream(resp.getOutputStream());<br />
task.setRenderOption(options);<br />
<br />
// pass parameters to the report<br />
task.addScriptableJavaObject("begin", begin);<br />
task.addScriptableJavaObject("end", end);<br />
task.addScriptableJavaObject("fileid", fileid);<br />
<br />
task.run();<br />
task.close();<br />
<br />
<br />
In the dataset open method I invoke the class in the following way<br />
<br />
<br />
count = 0;<br />
blotterDao = new Packages.com.bear.gcs.tm.admin.da.BlotterReportDaoImpl();<br />
blotter = blotterDao.getRejectedBlotter(begin, end,fileid);<br />
<br />
<br />
<br />
The servlet class has been configured in the web.xml<br />
<br />
Servlet class is invoked from the browser<br />
<br />
<a class='bbc_url' href='
http://localhost:3300/<domainname>/run?ReportName=trs_report.rptdesign&begin=20100501&end=20100505&output=pdf&fileid=1022114'>http://localhost:3300/<domainname>/run?ReportName=trs_report.rptdesign&begin=20100501&end=20100505&output=pdf&fileid=1022114</a><br
/>
<br />
But for each request, the servlet is invoked two times. Sometimes more than 2 times.<br />
As a result of this, dataset open method is called more than once.<br />
<br />
How to make it the servlet is fired only once for each and every request<br />
<br />
Could you please help me ??<br />
<br />
Thanks
mwilliams
But is it attached to more than one report item? Multiple tables within your report? Is it attached to a table that's embedded within another? Does your user have parameters they select from this database? etc.
sgeovar
Hi
It is only one report.
Since report is using Script Datasource ,it is not directly calling any table.
When the report is called, it's open event is invoked.
Open event invokes the following class
count = 0;
blotterDao = new Packages.com.bear.gcs.tm.admin.da.BlotterReportDaoImpl();
blotter = blotterDao.getRejectedBlotter(begin, end,fileid);
This class calls the stored procedure and returns list of values.
I populate these values using the datasource fetch method.
Fetch method code follows.
if(count < blotter.size()){
row["account"] = blotter.get(count).getAccountId();
row["recType"]= blotter.get(count).getRecType();
row["side"]= blotter.get(count).getSide();
count++;
return true;
}
return false;
So the report is not directly related with any table.
It calls the class and get the list of values to get populated.
The parameters (begin, end, fileid) is passed to the open event from the servlet
task.addScriptableJavaObject("begin", begin);
task.addScriptableJavaObject("end", end);
task.addScriptableJavaObject("fileid", fileid);
task.run();
task.close();
If you need any more information please let me know.
mwilliams
I understand that you're talking about one report. I'm talking about your report design. Do you have more than one table in your BIRT report design bound to this scripted dataSet? In your BIRT report design, do you have an embedded table or a crosstab associated with this scripted dataSet? What all does your BIRT report look like? Let me know. Thanks!
mwilliams
Also, just so you know, the following is old code:
PDFRenderContext renderContext = new PDFRenderContext();
contextMap.put(EngineConstants.APPCONTEXT_PDF_RENDER_CONTEXT,
renderContext);
task.setAppContext(contextMap);
There is now a PDFRenderOptions which replaced this a while back if you want to simplify your code.
sgeovar
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="69747" data-time="1288104419" data-date="26 October 2010 - 07:46 AM"><p>
I understand that you're talking about one report. I'm talking about your report design. Do you have more than one table in your BIRT report design bound to this scripted dataSet? In your BIRT report design, do you have an embedded table or a crosstab associated with this scripted dataSet? What all does your BIRT report look like? Let me know. Thanks!<br /></p></blockquote>
<br />
Sorry for misunderstanding.<br />
In the report design, I used only one table. I created a BLANK REPORT.<br />
Then I added a table from the Palette. It is only one table and 10 columns.<br />
I don't use embedded table or a crosstab.<br />
<br />
It is only one table having column headers and values.<br />
<br />
Thanks
sgeovar
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="69749" data-time="1288104601" data-date="26 October 2010 - 07:50 AM"><p>
Also, just so you know, the following is old code:<br />
<br />
PDFRenderContext renderContext = new PDFRenderContext();<br />
<br />
contextMap.put(EngineConstants.APPCONTEXT_PDF_RENDER_CONTEXT,<br />
renderContext);<br />
<br />
task.setAppContext(contextMap);<br />
<br />
There is now a PDFRenderOptions which replaced this a while back if you want to simplify your code.
<br /></p></blockquote>
<br />
Could you show one example using the code you'r mentioning ?<br />
<br />
One more question<br />
<br />
task.addScriptableJavaObject - is also deprecated. Is there any other way to pass the parameter to the datasource events ?<br />
<br />
Thanks
mwilliams
Looks like you do most of the PDFRenderOption stuff already, so you can probably just get rid of the other part so that it looked something like this, which you pretty much already have.
PDFRenderOption options = new PDFRenderOption();
options.setOutputStream(resp.getOutputStream());
options.setOutputFormat("pdf");
task.setRenderOption(options);
sgeovar
Sorry for misunderstanding.
In the report design, I used only one table. I created a BLANK REPORT.
Then I added a table from the Palette. It is only one table and 10 columns.
I don't use embedded table or a crosstab.
It is only one table having column headers and values.
mwilliams
Hmmm. I'm not sure why you'd be getting multiple calls to your servlet if you have no parameters and only a simple table. Do both calls last the same amount of time? I've asked a couple others and they are not sure either.
sgeovar
Thank you very much
I,m not sure about the time. But everytime servlet is called two times.
I'have one more question
Insteadig of setting the parameter in task.addScriptableJavaObject() which is a deprecated method, i want to use setAppContext method of task.
Document asks to use e appcontext to pass the parameter
map.put("","");
task.setAppContext(contextMap);
In this case , how to get these paramenters from the dataset open method ??
If you have any sample code , please share it with me.
Thanks
cypherdj
Rather than setting the app context itself, what I would do is add values in the app context (though I've never passed the values as part of the task, but globally at report engine level):<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
reportEngine.getConfig().getAppContext().put(propName, propValue);
</pre>
<br />
then in your BIRT script, you would retrieve the value using:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
reportContext.getAppContext().get(propName)
</pre>
<br />
Let me know if that's of any help to you,<br />
Rgds,<br />
Cedric
sgeovar
<blockquote class='ipsBlockquote' data-author="'cypherdj'" data-cid="69831" data-time="1288264865" data-date="28 October 2010 - 04:21 AM"><p>
Rather than setting the app context itself, what I would do is add values in the app context (though I've never passed the values as part of the task, but globally at report engine level):<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
reportEngine.getConfig().getAppContext().put(propName, propValue);
</pre>
<br />
then in your BIRT script, you would retrieve the value using:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
reportContext.getAppContext().get(propName)
</pre>
<br />
Let me know if that's of any help to you,<br />
Rgds,<br />
Cedric<br /></p></blockquote>
<br />
Thank you very much Cedric.<br />
I'll test it.
sgeovar
Hi
Birt runtime has many plugin jars.
IF I want to deploy Birt application in J2EE environment , these plugin jars are needed.
Birt run time comes as a zip file, and I have to unzip and deploy.
Now it resides in
WEB-INF/platform/plugns
/configuration
Is there anyway to avoid it ?
If avoiding is not possible, can I use runtime Birt zip without unzipping it ?
Since there are a large number of jar files, deploment has become an issue from one version to another version.
My question is can I use Birt runtime zip file without unzipping it ? If yes, in which folder I have to put it ?
sgeovar
Hi
Birt plugin has huge number of jars.
Is it possible to customize this ?
Is it necessary to install all these jars (plugin )
Thanks
sgeovar
<blockquote class='ipsBlockquote' data-author="'cypherdj'" data-cid="69831" data-time="1288264865" data-date="28 October 2010 - 04:21 AM"><p>
Rather than setting the app context itself, what I would do is add values in the app context (though I've never passed the values as part of the task, but globally at report engine level):<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
reportEngine.getConfig().getAppContext().put(propName, propValue);
</pre>
<br />
then in your BIRT script, you would retrieve the value using:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
reportContext.getAppContext().get(propName)
</pre>
<br />
Let me know if that's of any help to you,<br />
Rgds,<br />
Cedric<br /></p></blockquote>
<br />
Hi Cedric<br />
<br />
I set the reportEngine.getConfig().getAppContext().put(propName, propValue) in the servlet.<br />
<br />
and tried to retrieve it in report's script(open event) - reportContext.getAppContext().get(propName)<br />
I got NULL. It's not working.<br />
<br />
When I use task.getAppContext().put(propName, propValue), I'm able to get the value in the report script.<br />
<br />
task.getAppContext().put() is working well.<br />
<br />
<br />
<br />
Thanks
birtuser89
Hey i m facing a similar problem. I am not able to figure out the solution in the above discussion.
I have created a BIRT report and this report is called from the servlet.
It has been deployed on the web.
When i deploy and test it, this servlet's doGet method is called 3 times exactly, instead of once.
Please help me to resolve this issue.
I am using the library to access the reports. The reports are displayed as html as well as pdf also.
Can the problem be related to the Birt reports ?