title: How to make an instance of facescontext
body: <p>I'm using springbatch to call a jasper report using JSF. The problem is when a call the method, the facescontext is always null, so I can get the session. For different issues that I had read, I realize that the problem is because the batch process is not in the JSF lifecycle. HOw can I make an instance of facescontext, so I can get the session information? I try to make a FacesServlet, but I'm not sure in which moment, can I call it, and how to obtain the request and response information.    </p>
  
  <pre><code>  HttpServletResponse httpServletResponse = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
          httpServletResponse.addHeader("Content-disposition", "attachment; filename=" + nombreReporte + ".pdf");
          ServletOutputStream servletOutputStream = httpServletResponse.getOutputStream();
          JasperExportManager.exportReportToPdfStream(jasperPrint, servletOutputStream);
          FacesContext.getCurrentInstance().responseComplete();
  </code></pre>