IntelliJ Java IDE
The moose likes Other Open Source Projects and the fly likes request.getSession() is null Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Reply Bookmark "request.getSession() is null " Watch "request.getSession() is null " New topic
Author

request.getSession() is null

ema kacurkova
Greenhorn

Joined: Feb 06, 2012
Posts: 1
Hi everyone, i will appreciate if someone help me with the following problem.
I have a jasper report which i fill in a PrintingBean and its all good. The moment i clicked on a print preview button (opening the applet) my app throws a null pointer exception at
PrintingBean bean = (PrintingBean) request.getSession().getAttribute("printMB"); line....
it seems like it makes new session (but i cant see that on gui, its all good). My manageBean is a SessionScoped. This is my whole method:

private void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

JasperPrint jasperPrint = null;

try {
PrintingBean bean = (PrintingBean) request.getSession().getAttribute("printMB");
if (bean.getPrintingDataList() != null && !bean.getPrintingDataList().isEmpty()) {
jasperPrint = printManager.print(bean.getPrintingDataList());
}
} catch (Exception ex) {
Logger.getLogger(JasperPrintServlet.class.getName()).log(Level.SEVERE, null, ex);
}
if (jasperPrint != null) {
response.setContentType("application/octet-stream");
ServletOutputStream ouputStream = response.getOutputStream();

ObjectOutputStream oos = new ObjectOutputStream(ouputStream);
oos.writeObject(jasperPrint);
oos.flush();
oos.close();

ouputStream.flush();
ouputStream.close();
}
}

Thanks Ema

thippe swamy
Greenhorn

Joined: Feb 04, 2012
Posts: 10

try creating the session object in aseparate line and use that object.
 
 
subject: request.getSession() is null
 
Threads others viewed
How to open a PDF in a Portlet
tomcat connection
Jasper Report Line Graph
how get datasource object in sun java studio creater
Jasperreports + Struts
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com