| Author |
Problem trying to send file to browser in JSF
|
Stefan Rasmusson
Greenhorn
Joined: Feb 25, 2010
Posts: 5
|
|
Hi I've tried two different techniques for sending a file to a browser(making the user download a file). I've tried an example from myfaces wikipage
I have also tried using a component named fileDownload from PrimeFaces. Both give the same result:
I get a response from the server, the response contains text that should be in the file. The header is a follows:
X
To me this looks correct but for some reason I don't get to download the file, I just get this response in firebug.
Does anyone have any idea?, could it be a serversetting problem? I using glassfish 3
Thanks / Stefan
|
 |
prasenjitkumar das
Greenhorn
Joined: Mar 17, 2010
Posts: 12
|
|
Try using "application/force-download" instead of "text/plain".
Regrds,
Prasenjit
|
 |
Stefan Rasmusson
Greenhorn
Joined: Feb 25, 2010
Posts: 5
|
|
It didn't work. I think the problem lies in JSF and facelets. I use a facelet and a template.
Template
Facelet
But if I rewrite the facelet like this, the download works, and it works with the mimetype text/plain
Any ideas?
|
 |
Janardan Thakar
Greenhorn
Joined: May 21, 2010
Posts: 2
|
|
Try this.
response.setContentType("application/vnd.ms-word");
Because for the plain text some time browser displays content directly in the screen instead of giving download option.
|
 |
Stefan Rasmusson
Greenhorn
Joined: Feb 25, 2010
Posts: 5
|
|
It figured out the problem.
I was using the primefaces commad button that does a partial ajax submit. Changed to jsf commandbutton and everything works
|
 |
 |
|
|
subject: Problem trying to send file to browser in JSF
|
|
|