Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

JSF How to load Files

Posted on 2004-10-20
3
Medium Priority
?
618 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 2000 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
If you have come across a situation where you need to find some EDB mailbox recovery techniques, then here you will find the same. In this article, we will take you through three techniques using which you will be able to perform EDB recovery. You …
Integration Management Part 2
Loops Section Overview
Suggested Courses

916 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