Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 982615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:43:34+00:00 2026-05-16T04:43:34+00:00

which is the right way to download a file using JSF?, just putting a

  • 0

which is the right way to download a file using JSF?, just putting a link to the file ?? in that case how do i get the file URL??

i have seen one example using BufferedInputStream:

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

What are the differences?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T04:43:35+00:00Added an answer on May 16, 2026 at 4:43 am

    If it’s a simple file, just place in public webcontent (there where you put your static and JSF files) and create a link.

    <h:outputLink value="/files/file.ext">link</h:outputLink>
    

    The servletcontainer will worry about applying the correct headers.

    If it’s located outside the public webcontent for some specific reasons (e.g. in a fixed path at server machine, or in a database), then create a servlet which gets an InputStream of it and writes it to the OutputStream of the response along at least the Content-Type, Content-Disposition and Content-Length headers. You can find here a simple kickoff example. Also that can simply be linked on the servlet’s url-pattern.

    If it’s to be dynamically generated and depending on the JSF specific request parameters, then you can also do so in a managed bean action which is bound by h:commandLink or h:commandButton, but you only need to ensure that you call FacesContext#responseComplete() at end of bean’s action method to prevent JSF from taking the navigation in hands. The same kind of servlet code can be reused to stream the file. You can find a kickoff example in this answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this design which I cannot seem to get right, I would like
I have a site, from which you can download an HTML file. This HTML
I have a multi-select box which has 2 buttons on the right which are
We have a script right now which our Windows users run on a Linux
I Have wrote a question which got a right answer here about emysql encoding.
In my app I have a stickman, which moves to right when you click
Right now I have this SQL query which is valid but always times out:
I have this code which compiles and works as expected: class Right {}; class
I want to download the same information which is obtained when we right click
I have 2 models which look like that: class Entry(models.Model): user = models.ForeignKey(User) dataname

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.