Solved

JSF How to load Files

Posted on 2004-10-20
3
615 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Display the newly inserted values 3 88
lessBy10  challenge 15 97
How to find missing packages when using Netbeans IDE 8.1 ? 19 84
How to set default webapp for host 6 47
This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
Had a business requirement to store the mobile number in an environmental variable. This is just a quick article on how this was done.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

738 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