tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Guilherme Orioli" <gui.ori...@gmail.com>
Subject Re: How can I refresh tomcat in the java code?
Date Thu, 03 Apr 2008 11:51:06 GMT
Didn't get it... it just doesn't work... what do I need to use instead of
the response.redirect ?

2008/4/2, Alan Chaney <alan@compulsivecreative.com>:
>
> You don't need the redirect. The response to the request IS the pdf file.
>
> HTH
>
>
> Guilherme Orioli wrote:
>
> > It just doesn't show the Download dialog on the screen when i click the
> > button...
> >
> > 2008/4/2, Guilherme Orioli <gui.orioli@gmail.com>:
> >
> > > ok... here's what i'm doing... in system out, something like a pdf
> > > file is
> > > printed... itÅ› probably there... just don't know how to show it from
> > > the
> > > button i'm clicking on:
> > >
> > > public String geraReportBois(){
> > > try{
> > >
> > > //Generating the report
> > > String caminho_arquivo = new File("").getAbsolutePath() +
> > > "/workspace/safeTrace/WebContent/reports/cliente/frigorifico/";
> > > String nome_arquivo = "reportBois.jasper";
> > > JasperReport jasperReport =
> > > (JasperReport)JRLoader.loadObject(caminho_arquivo + nome_arquivo);
> > > Map parameters = new HashMap();
> > > parameters.put("Caminho", caminho_arquivo);
> > > JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,
> > > parameters, this.getRelatorioBois());
> > >
> > >
> > > //----------------------------------------------------------------------------------
> > >
> > > //Exporting to File (outputStream)
> > > ByteArrayOutputStream pdfStream = new ByteArrayOutputStream();
> > > JasperExportManager.exportReportToPdfStream(jasperPrint, pdfStream);
> > >
> > > HttpServletResponse response = (HttpServletResponse)
> > > FacesContext.getCurrentInstance().getExternalContext().getResponse();
> > > response.setContentType("application/pdf");
> > > response.setHeader("Content-Disposition", "inline;
> > > filename=myPDF.pdf");
> > > response.setContentLength(pdfStream.size());
> > > try{
> > > ServletOutputStream sos = response.getOutputStream();
> > > pdfStream.writeTo(sos);
> > > System.out.println("pdsStream - "+pdfStream);
> > > response.sendRedirect("myPDF.pdf");
> > > sos.flush();
> > > sos.close();
> > > pdfStream.close();
> > > pdfStream = null;
> > > }catch(IOException e){
> > > e.printStackTrace();
> > > }
> > > return "";
> > >
> > > }catch(JRException e){
> > > System.out.println("entrou no catch geraReportBois");
> > >
> > > e.printStackTrace();
> > > }
> > > return null;
> > > }
> > >
> > >
> > >
> > >
> > >
> > !DSPAM:47f3d27e207721697119596!
> >
> >
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message