I am using JSF 1.1. On click of a button I need to download a file from webapp/pdf
directory. How can I achieve this?
Asked
Active
Viewed 513 times
0

BalusC
- 1,082,665
- 372
- 3,610
- 3,555

Jagannath Sabat
- 118
- 3
1 Answers
2
Just link to its URL directly. Both the server and the browser will do the necessary magic.
The desired HTML output should look like this:
<a href="/yourcontext/pdf/filename.pdf">
Download PDF
<a>
The JSF 1.1 on JSP way to generate this HTML is:
<h:outputLink value="${pageContext.request.contextPath}/pdf/filename.pdf">
<h:outputText value="Download PDF" />
</h:outputLink>
Or, when you're using JSF 1.1 on Facelets:
<h:outputLink value="#{request.contextPath}/pdf/filename.pdf">
Download PDF
</h:outputLink>
If necessary, throw in some CSS to make it look like a "button".

BalusC
- 1,082,665
- 372
- 3,610
- 3,555
-
Thanks Balus,