Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Path Problem

Status
Not open for further replies.

lusujin

Programmer
Joined
Jan 12, 2004
Messages
3
Location
FR
Hi there,
i current have some jsp pages running on tomcat 4.1.12.
This jsp pages reads some data file from a certain location.
For now i can only get the jsp pages to work by specifying the absolute path to this input files.
If i do not, i will have to copy these input files into the <CATALINA_HOME>/bin directory for it to work.

Is there any way, I could specify in TOMCAT to look for these files else where in the filesystem.

Thanks very much,
lui
 
You can get the absolute path for the web root in a JSP by:

getServletContext().getRealPath(&quot;/&quot;);

So, if you place your data file anywhere under web root, you can then determine its absolute path at runtime.

e.g. if you place your data file, say myData.dat in <
<webRoot>/WEB-INF/myData.dat

then you can determine it absolute path at run time and obtain a File object in a JSP using:

File dataFile = new File(getServletContext().getRealPath(&quot;/&quot;), &quot;WEB-INF/myData.dat&quot;);
 
Thanks very much.
It resolved my problem!!
u da best!



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top