struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Gainty <mgai...@hotmail.com>
Subject RE: [OT] Re: [S2] Locating a file or resource in Web application (classpath issue)
Date Thu, 11 Dec 2008 20:27:18 GMT

eclipse 3.2
file/new/Java/Tomcat Project(war)

follow dave's advice using ServletContext.getRealPath(...) to get absolute path from relative
path..

hth
Martin 
______________________________________________ 
Disclaimer and confidentiality note 
Everything in this e-mail and any attachments relates to the official business of Sender.
This transmission is of a confidential nature and Sender does not endorse distribution to
any party other than intended recipient. Sender does not necessarily endorse content contained
within this transmission. 




> Date: Thu, 11 Dec 2008 11:05:58 -0800
> From: milanmilanovich@yahoo.com
> To: user@struts.apache.org
> Subject: Re: [OT] Re: [S2] Locating a file or resource in Web application (classpath
issue)
> 
> 
> O.K. Thanks.
> 
> When I deploy application to local Tomcat from my Eclipse environment it
> don't use WAR, but if I want to run my app on server's Tomcat I'll need to
> have application in war, isn't it ?
> 
> --
> M.
> 
> 
> newton.dave wrote:
> > 
> > --- On Thu, 12/11/08, Milan Milanovic wrote:
> >> If I try to say e.g.:
> >> PropertiesConfiguration config = new
> >>     PropertiesConfiguration("/WEB-INF/users.properties");
> > 
> > You're assuming path names are magically converted into web-app-relative
> > paths inside a web application; this isn't the case.
> > 
> > Nor is this a classpath issue if you're trying to get files from the
> > filesystem. If you *are* trying to access resources from the classpath
> > then the resources would need to be on the classpath, which is
> > /WEB-INF/classes (by default, anyway).
> > 
> > If you are accessing *filesystem* resources then you need to convert
> > web-app-relative paths like "/WEB-INF/users.properties" into an actual
> > path. Things like ServletContext.getRealPath(...) are good for that.
> > 
> > Unless you're deploying an un-exploded WAR file, in which case it will
> > fail, which is why people like getting things from the classpath.
> > 
> > Dave
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> > 
> > 
> > 
> 
> -- 
> View this message in context: http://www.nabble.com/-S2--Locating-a-file-or-resource-in-Web-application-%28classpath-issue%29-tp20959786p20962267.html
> Sent from the Struts - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

_________________________________________________________________
Send e-mail anywhere. No map, no compass.
http://windowslive.com/Explore/hotmail?ocid=TXT_TAGLM_WL_hotmail_acq_anywhere_122008
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message