0

I trying to make simple web Application (JSF2 + Tomcat7). I have an idea to make reports as *.pdf file in the specified directory and than redirect client to that file.

I have configured Tomcat to "see" directory /data/uploads by address http://localhost:8080/uploads and it's work fine. I can view content of file /data/uploads/sample.txt as /uploads/sample.txt.

I tried to write content in text file via method of ManagedBean, but already have a few questions, that I can't find in any books:

  1. My test JSF application has /jsfincubator as context path. Is there any way to access sample.txt via path like /uploads/sample.txt, that is same to GET request path? I can successfully write to file by it's absolute path /data/uploads/sample.txt, but I want to abstract from absolute paths or make this path configurable.
  2. How can I make link to file /uploads/saple.txt from my test application? All my variations with links can't be resolved.
  3. Is it possible to make ManagedBean's method, that will be write content into file and return the path of that file to redirect browser?

Thanks for wasting your time for me. Best regards.

gooamoko
  • 658
  • 11
  • 29
  • If your file is public, `h:outputLink` is the way to go for accessing it. http://stackoverflow.com/questions/3428039/download-a-file-with-jsf You can perform your business in your action method and then make a redirection to your desired path. – Aritz Feb 19 '14 at 10:20
  • Thank you for your answer and link. – gooamoko Feb 20 '14 at 05:48

0 Answers0