Solved

JSF How to load Files

Posted on 2004-10-20
3
612 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
iterator example remove 8 74
eclipse luna javeEE perspecive missing 5 109
main method of string class 3 110
null output 3 24
One of the biggest threats facing all high-value targets are APT's.  These threats include sophisticated tactics that "often starts with mapping human organization and collecting intelligence on employees, who are nowadays a weaker link than network…
SEO can be a real minefield to navigate, but there are three simple ways to up your SEO game just be re-assessing your content output.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

808 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