Dear ones..
I am calling .prpt file from below servlet........
import java.io.IOException;
import java.util.HashMap;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.net.URL;
import java.io.PrintWriter;
import org.pentaho.reporting.engine.classic.core.MasterRe port;
import org.pentaho.reporting.engine.classic.core.ReportPr ocessingException;
import org.pentaho.reporting.engine.classic.core.ClassicE ngineBoot;
import org.pentaho.reporting.engine.classic.core.modules. output.pageable.pdf.PdfReportUtil;
import org.pentaho.reporting.libraries.resourceloader.Res ourceCreationException;
import org.pentaho.reporting.libraries.resourceloader.Res ourceException;
import org.pentaho.reporting.libraries.resourceloader.Res ourceKeyCreationException;
import org.pentaho.reporting.engine.classic.core.modules. output.table.xls.ExcelReportUtil;
import org.pentaho.reporting.libraries.resourceloader.Res ourceLoadingException;
import org.pentaho.reporting.engine.classic.core.modules. output.table.html.HtmlReportUtil;
import org.pentaho.reporting.libraries.resourceloader.Res ourceManager;
import org.pentaho.reporting.libraries.resourceloader.Res ource;
import javax.servlet.http.HttpServlet;
protected void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
out.println("<h1>HIiiiiiiiiiiiiiiiiiiiiiiii</h1>");
try {
String reportPath = "file:" + this.getServletContext().getRealPath("reports/First_report.prpt");
loadReport(response,reportPath,"pdf", new HashMap());
}catch(Exception e){
e.printStackTrace();
}
}
public static void loadReport(HttpServletResponse response, String reportPath, String reportFormat, HashMap reportParams)
throws ServletException, IOException, ReportProcessingException, ResourceLoadingException, ResourceCreationException,
ResourceKeyCreationException, ResourceException {
try {
// initializing the Pentaho reporting Engine.
ClassicEngineBoot.getInstance().start();
// loading report definition
ResourceManager manager = new ResourceManager();
manager.registerDefaults();
Resource res = manager.createDirectly(new URL(reportPath),
MasterReport.class);
MasterReport report = (MasterReport) res.getResource();
//puting input parameters to report
for (Object key : reportParams.keySet()) {
report.getParameterValues().put(key.toString(), reportParams.get(key));
}
if (reportFormat.equals("pdf")) {
response.setContentType("application/pdf");
PdfReportUtil.createPDF(report, response.getOutputStream());
} else if (reportFormat.equals("html")) {
response.setContentType("application/html");
HtmlReportUtil.createStreamHTML(report, response.getOutputStream());
} else if (reportFormat.equals("xls")) {
response.setContentType("application/vnd.ms-excel");
ExcelReportUtil.createXLS(report, response.getOutputStream());
}
/*} catch (org.pentaho.reporting.libraries.resourceloader.Re sourceException e) {
e.printStackTrace();
}*/
//set null after usage
manager=null;
res=null;
report=null;
} catch (ResourceException ex) {
//logger.fatal("Exception ", ex);
}
And i am using mozilla....and when run the servlet i am getting following error in the browser
File does not begin with '%PDF-'
Please friends help me