free web page hit counter
Sunday Nov 13, 2005

How to create a file download link ina JSF page?

Suppose you want to create a page and place lots of links in it. What you want is, when your user clicks on a link, it should open the browser's standard Save as dialog box, even if the browser knows how to handle the MIME type. Your user can then choose a location to save the file and move on. How to do this using a hyperlink component in Sun Java Studio Creator 2?

Read more about the tip at

http://winstonprakash.com/articles/jsf/file_download_link

Comments:

Is it possible to create a program in "SUN Java Creator 2" which login into a certain website and then go to a certain hyperlink(webpage) and then downloads the file that is residing on that webpage?

Posted by Cassim on November 20, 2005 at 05:11 PM PST #

So much hassle just to change the response content type to "application/force-download"? Why do we have to send the data manually? Will it work if I just modify the header and leave the rest intact?

Posted by Ivanb on April 12, 2006 at 11:39 AM PDT #

How come if I add a new hyperlink on your sample code, after clicking on the download hyperlink (which downloads the file correctly), whenever I click the new hyperlink, the download dialog box is always shown and not the action its supposed to do? Is this a hyperlink bug? Its been a while and 2 hotfixes had already been released and this issue is not yet addressed. Any update on this one? You may refer to my post here: http://forum.sun.com/jive/thread.jspa?forumID=123&threadID=59323 Thanks.

Posted by eebora on September 21, 2006 at 03:00 AM PDT #

Now, this is interesting. I have tried to check what is the cause of this problem. When you try refreshing the page after clicking the download link, the new hyperlink will work as expected. The page was reloaded after clicking the download link. What is the difference between refresh from the browser and page reload in jsf? I think there is something in the hyperlink that was not reinitialized when the page reload was called thus causing the problem to occur.

Posted by eebora on September 22, 2006 at 12:25 AM PDT #

How can i download the file from server to the client ?

Posted by S.Sasikumar on November 02, 2006 at 11:14 PM PST #

How can i download the file from server to the client Using JSP or SERVLETS?

Posted by S.Sasikumar on November 02, 2006 at 11:15 PM PST #

Hello Winston! Thanks for cool tip. I'd spend ages trying to figure out how to do it. I'v got one little problem though... After clicking the link dialog box opens. I save it and everything is ok. When i want to go to another page or tab on the same page dialog box opens again... i have to click cancel download and than i can finally go to another page. any idea what might be wrong ? What i thought of was virtual forms but it isn't solving this problem. Thanks for you time! dElay

Posted by dElay on March 08, 2007 at 03:11 AM PST #

fuck off

Posted by 61.11.49.185 on March 26, 2007 at 07:15 AM PDT #

i have a table with hyperlink on each role to download a file from my local machine at first when i click the first link it worked correctly and could save my download if i click on another tab on the page the same dialog box will open unless i click the back and front button on the browser. can anyone help.

Posted by wales on July 19, 2007 at 12:33 PM PDT #

Thanks for the Tips!
I have few questions need your advice.

1)what will happen when the client connection is broken while downloading a very huge file?
In my environment, the page process overload the server.
2)how to support resume for the previous case.

Posted by Kenny on August 15, 2007 at 03:39 AM PDT #

trhdfgh

Posted by 72.71.210.123 on November 21, 2007 at 02:40 PM PST #

Is it possible to achieve the above mentioned solution using html and javascript alone?

Posted by Diksha on February 08, 2008 at 03:36 AM PST #

Post a Comment:
  • HTML Syntax: NOT allowed