tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Moore" <tmo...@blackboard.com>
Subject RE: How do I access files above and below \web-inf folder?
Date Mon, 02 Dec 2002 16:31:13 GMT
You should probably use ServletContext.getResource or
ServletContext.getResourceAsStream

http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletConte
xt.html#getResource(java.lang.String)

http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletConte
xt.html#getResourceAsStream(java.lang.String)

That way, it will still work if your web app is packaged as a WAR file.
The path argument is context-relative.

-- 
Tim Moore / Blackboard Inc. / Software Engineer
1899 L Street, NW / 5th Floor / Washington, DC 20036
Phone 202-463-4860 ext. 258 / Fax 202-463-4863


> -----Original Message-----
> From: Mehdi.Nejad@bluewave.com [mailto:Mehdi.Nejad@bluewave.com] 
> Sent: Monday, December 02, 2002 5:06 AM
> To: Tomcat Users List
> Subject: RE: How do I access files above and below \web-inf folder?
> 
> 
> 
> I use the getRealPath,
> 
> String pathToPropsFile = config.getServletContext().getRealPath
> ("WEB-INF/properties/");
> 
> use "/", as this also works on win platforms, and does not 
> need escaping. You should be able to use a relative going up 
> the tree, in the argument ("../foo/bar");
> 
> cheers,
> 
> Mehdi

--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message