What about creating one more singleton object that is constructed with
the ServletContext, and then all of the other objects use that one to
access the file?  It's probably a good idea to encapsulate access to the
file anyway.

-- 
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: Etienne [mailto:[EMAIL PROTECTED]] 
> Sent: Friday, February 07, 2003 5:28 PM
> To: 'Tomcat Users List'
> Subject: RE: How to get the web application or Tomcat path 
> inside a class
> 
> 
> It is because the applications work with a lot of "interne" 
> singleton objects (one instance for all the application). 
> Like a ConnectionPool or a ApplicationScopeUtil that do not 
> need to know the actual request, of servlet context: this 
> would add a unused parameter to all the methods and mix up 
> everything, and maybe creating new thread problems... 
> 
> So, for now, I don't want to put inside each singleton object 
> a constructor asking for the ServletContext parameter... or 
> HttpServletRequest parameter... everything is working well 
> without any request indication. But when I need to get a file 
> on the drive, I need to know where is the tomcat path... That 
> is the only problem here. There is no way to get the 
> CATALINA_HOME of the JVM?
> 
> E.L
> 
> -----Original Message-----
> From: Tim Moore [mailto:[EMAIL PROTECTED]] 
> Sent: February 7, 2003 5:14 PM
> To: Tomcat Users List
> Subject: RE: How to get the web application or Tomcat path 
> inside a class
> 
> Why don't you have access to the ServletContext?  That's 
> really the only portable way to access resources in your webapp.
> 
> -- 
> 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: Etienne [mailto:[EMAIL PROTECTED]]
> > Sent: Friday, February 07, 2003 5:01 PM
> > To: 'Tomcat Users List'
> > Subject: How to get the web application or Tomcat path 
> inside a class
> > 
> > 
> > Hi,
> > 
> > Is there a way to get the web application path or the tomcat
> > path inside a java bean not using any "Request" object? I am 
> > running tomcat on Windows. I need sometime to access xml file 
> > placed on the <web_app_path>/xml/ folder. On windows, it is 
> > easy to retrace them because the starting (default) path for 
> > retrieving a file is based on the web application path. So 
> > new File("xml/myfile.xml") works. 
> > 
> > But on the unix box, the starting (default) path is at
> > <tomcat_path>/bin/. I don't want to put my xml files there. 
> > So, is there a way (without the 
> > servletContext.getRealPath("//");  method, because I don't 
> > have access to the servletContext object ) to retrieve the 
> > path of the tomcat path or better,  the Web Application path?
> > 
> > tks
> > 
> > E.L.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to