Olá pessoal, estou tentando abrir um PDF no Browser e se alguém puder me ajudar com esta eu agradeço:
tenho um JSP com o seguinte código:
<h:commandLink action="#{hotSiteIniBean.printDraftSample}">
<h:graphicImage url="img/printItem.gif" title="Print" alt="Print"/>
<t:updateActionListener property="#{hotSiteIniBean.cd}" value="#{dst.cd}" />
</h:commandLink>
a função do MBEAN tá assim:
String jasperPath = new String("...");
Connection con = new MyConnection().getCon();
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("pathSubReport", jasperPath + "productionShippedItem.jasper");
HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
ServletOutputStream servletOutputStream = response.getOutputStream();
byte[] bytes = null;
bytes = JasperRunManager.runReportToPdf(jasperPath + "productionShipped.jasper",parameters,con);
response.setContentType("application/pdf");
response.setContentLength(bytes.length);
servletOutputStream.write(bytes, 0, bytes.length);
servletOutputStream.flush();
servletOutputStream.close();
mas na linha do RunManager.runReportToPdf retorna o seguinte erro no browse:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Error calling action method of component with id _idJsp7:data:0:_idJsp35
javax.faces.webapp.FacesServlet.service(FacesServlet.java:154)
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
root cause
javax.faces.FacesException: Error calling action method of component with id _idJsp7:data:0:_idJsp35
org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
javax.faces.component.UICommand.broadcast(UICommand.java:109)
javax.faces.component.UIData.broadcast(UIData.java:517)
javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171)
org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.