Further information on:
http://www.onjava.com/pub/a/onjava/excerpt/java_cookbook_ch18/?page=6
I solved this problem this way:
public void exportFile() {
FacesContext context = FacesContext.getCurrentInstance();
HttpServletResponse response =
(HttpServletResponse)context.getExternalContext().getResponse();
response.setContentType("application/pdf");
response.setHeader("Content-disposition",
"inline=filename=file.pdf");
try {
response.getOutputStream().write(yourdata[]);
response.getOutputStream().flush();
response.getOutputStream().close();
context.responseComplete();
} catch (IOException e) {
e.printStackTrace();
}
Hi,
does anybody know an easy way to stream a file to the browser with jsf?
My current solution is a commandLink that calls a blank jsf page with some
parameters and this contains a forward to a servlet that does the streaming.
The problem is once the user has opened a file, myfaces somehow looses
it's navigation state and opens the current page whereever I click next
time.
Any help appreciated.
Carsten
--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.10.13/78 - Release Date: 19.08.2005
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.10.13/78 - Release Date: 19.08.2005