Kush Sahu

Greenhorn
+ Follow
since Jan 08, 2013
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Kush Sahu

I want to download a file in my jsf project. At bean side I am getting object of DataHandler. I tried to search many times but I did not found anything related to it. How can I download a file through datahandler object?

DataHandler src = attachment.getAttachment();

ByteArrayOutputStream output = new ByteArrayOutputStream();
src.writeTo(output);
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
externalContext.setResponseHeader("Content-Type", src.getContentType());
externalContext.setResponseHeader("Content-Disposition", "attachment;filename=sachin.jpg");
externalContext.getResponseOutputStream().write(output.toByteArray());
facesContext.responseComplete();

And if anybody knows about a good tutorial on file download and file upload which describes whole process in detail would be great for me.
11 years ago
JSF