Solved

JSF How to load Files

Posted on 2004-10-20
3
614 Views
Last Modified: 2011-10-03
Well I have a little problem that cause me a lot of trouble.
I have created my first jsf web site based on xml files so in my java code I load those files and process it.
In the development phase the pats of the files was kind of hardcoded laike absolute path and now , when evrything else is done, I m having problem placing tis site on the server because I can found the way for loading Files with relative paths on the server.
I need just those one or two lines to get File from the public-html folder...

String sRoot = methodToGetRootFoolder();

0
Comment
Question by:cubrovic
  • 2
3 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 500 total points
ID: 12367694
<%
  URL theFile = pageContext.getServletContext().getResource( "/file/relative/to/webapp/root.txt" ) ;
%>

should do it?

ie:  if the files are in the webapp's root directory, then:

<%
  URL theFile = pageContext.getServletContext().getResource( "/file.txt" ) ;
%>

should return a URL for it (which you can then use to load the resource)
0
 
LVL 7

Author Comment

by:cubrovic
ID: 12555323
That's the way.
I have used getRealPath instead of getResource but that is it.
Thanks
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12555370
:-)

Glad I could point you in the right direction :-)

Good luck with it all :-)

Tim
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

5 Ways to automate alert management in ConnectWise // The art of alerting is in automation. When humans are removed from the alerting process, errors are fewer and action is almost immediate. But how do you automate the alerting process and what …
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question