Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Link for getting a report from server
yusufnazir
Hi All,
I have a java application integrated with the birt engine API running on a tomcat server. I'm still testing out stuff. What I want to know is after i've created a report and stored it in a directory within a folder in the webapp, how do I generate a link to the report to be accessable to different clients?
thanks in advance
Yusuf
Find more posts tagged with
Comments
JasonW
Yusuf,
Can you give some more detail?
In your servlet you can always open the report designs like:
design = birtReportEngine.openReportDesign( yourServletContext.getRealPath("/Reports")+"/"+reportName );
The /Reports directory would be in your webapp.
Jason
yusufnazir
Hi Jason,
Thanks for the reply.
I solved the problem.
I am working with spring mvc en i was getting and error when i called getOutputStream() method because i was returning a view within my controller class.
Here's the controller class that works:
public class PDFController extends AbstractController {
protected ModelAndView handleRequestInternal(HttpServletRequest req, HttpServletResponse resp) throws Exception {
ServletOutputStream out;
String reportName = req.getParameter("ReportName");
ServletContext context = req.getSession().getServletContext();
String sessionId = new String(req.getSession().getId());
String report = new String(reportName.concat(".pdf"));
resp.addHeader("Content-Disposition", "attachment; filename="" + "WEB-INF/tempReports/"+sessionId+"/"+report+ """);
byte[] buf = new byte[1024];
try{
String realPath = context.getRealPath("WEB-INF/tempReports/"+sessionId+"/"+report);
File file = new File(realPath);
long length = file.length();
BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
out = resp.getOutputStream();
resp.setContentLength((int)length);
while ((in != null) && ((length = in.read(buf)) != -1)) {
out.write(buf, 0, (int)length);
}
in.close();
out.close();
}catch (Exception exc){
exc.printStackTrace();
}
return null;
}
}
instead of returning null i was returning new ModelAndView("........")