Jump to content
We've recently updated our Privacy Statement, available here ×

How to use xml data source on jasper server


maciejwenerski

Recommended Posts

Hi, I would like to use xml data source in jasper server (5.0.0). Xml files are created "on the fly" while application is running so different reports will have different xml data sources. I know that jasper server does not have XML data source defined but I found out that creating report without data source and then passing parameter XML_FILE - java.io.File will do the work. I managed to do this in java servlet: 

      jasperReport = JasperCompileManager.compileReport("C://FileIO//XMLDSReport.jrxml");       
      HashMap map  = new HashMap();
      map.put("XML_FILE", new File(xmlSourceFile));     
      jasperPrint = JasperFillManager.fillReport(jasperReport,map);        
    byte [] o = JasperExportManager.exportReportToPdf(jasperPrint);
 
but unfortunately failed to do it on jasper server. I've tried to write a scriptlet that converts String parameter with xml url to java.io.File 
 
    public class XmlScriplet extends JRDefaultScriptlet{
   @Override
public void beforeReportInit(){
try {
String param = (String)this.getParameterValue("fileName");
HashMap map  = new HashMap();
map.put("XML_FILE", new File(param));
this.parametersMap.putAll(map);
 
 
} ...
 
but this gives me an empty report. 
Thank you in advance.
Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...