Note: error is comming @ line: 59
This is the source code where i m getting nullpointer exception , I am unable to know where exactly this is not getting value. this code is working at another machine but not on my machine though i compiled it from machine on which its working
plz help i got stuct @work
public void generateReport(String ctype,String cstype,String locid,String orgId,HttpServletRequest request,HttpServletResponse response,String reportname) throws ServletException,IOException,SAXException
{
PrintService service = null;
InputStream input=null;
Connection con=null;
ServletContext servletCtx=null;
System.out.println("jasper report name"+reportname);
try{
con = Connect.getConnection();
String path="C:/Program Files/Apache Software Foundation/Tomcat 5.5/webapps/"+request.getContextPath()+"/jReport/";
String realPath = request.getRealPath("/jReport/"+reportname+".jasper");
System.out.println("generateDeathReport path="+path);
System.out.println("generateDeathReport realPath="+realPath);
String rFile=request.getRealPath("/jreport/"+reportname+".jasper");
File RFile= new File(request.getRealPath("/jreport/"+reportname+".jasper"));
JRPdfExporter pdfExporter = new JRPdfExporter();
Map rptHash = new HashMap();
FontKey key = new FontKey("ArialUNI", false, false);
/* rptHash.put("typeId", ctype);
rptHash.put("sub_typeId", cstype);
rptHash.put("orgId", orgId);
rptHash.put("locid", locid); */
rptHash.put("typeId", "0");
rptHash.put("sub_typeId", "0");
rptHash.put("orgId", "2");
rptHash.put("locid", "0");
System.out.println("TYPEID==sub_typeId==orgId=="+rptHash);
FileInputStream fs=new FileInputStream(rFile);
JasperReport template=(JasperReport)JRLoader.loadObject(RFile);
System.out.println("Loaded Successfully the jasper file!!");
//JasperPrint report=JasperFillManager.fillReport(template,rptHash,con);
System.out.println("Report filled with data");
FileInputStream reportSource=new FileInputStream(rFile);
System.out.println("file found"+reportSource);
try
{
System.out.println("CON==="+con);
System.out.println("rptHash==="+rptHash);
System.out.println("reportSource==="+reportSource);
================================================================================
//this is line where i m getting null pointer exception
===============================================================================
JasperPrint oJasperPrint = JasperFillManager.fillReport(reportSource,rptHash, con);
System.out.println("oJasperPrint");
response.setContentType("application/pdf");
pdfExporter.setParameter(JRPdfExporterParameter.CHARACTER_ENCODING, "UTF-8");
JasperExportManager.exportReportToPdfStream(oJasperPrint,(OutputStream)response.getOutputStream());
System.out.println("2. Pdf report generated..");
response.setContentType("application/pdf");
pdfExporter.exportReport();
System.out.println("REPORT GENERATED");
response.getOutputStream().flush();
} catch(JRException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
}
}catch(JRException jex)
{System.out.println("Jasper Exception :"+jex.getMessage());
System.out.println("Jasper Exception :"+jex.getStackTrace());
System.out.println("Jasper Exception :"+jex.getLocalizedMessage());
}
catch(Exception e)
{
System.out.println("EXCEPTION IN jaspaer1 CLASS-generateReport()-e="+e);
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
e.printStackTrace(printWriter);
response.setContentType("text/plain");
//response.getOutputStream().print(stringWriter.toString());
}
}