tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bryan Austad" <baus...@xtendsoft.com>
Subject RE: Loading property files using ClassLoader.getSystemResource()
Date Wed, 13 Feb 2002 17:30:59 GMT
Sorry...solved it.  Did this...

        static public String formFullPath( String fName )
   {
      URL url;

      if (fName.charAt(0) == '/'){
         System.out.println("fName is " + fName);
         return fName;
      }   
      //url = ClassLoader.getSystemResource(fName);
      ClassLoader cl = ClassLoader.getSystemClassLoader();
      url = cl.getResource(fName);
      System.out.println("url is " + url);
      return (url == null) ? fName : url.getFile();
   }

-----Original Message-----
From: Christopher K. St. John [mailto:cks@distributopia.com]
Sent: Wednesday, February 13, 2002 11:00 AM
To: Tomcat Users List
Subject: Re: Loading property files using
ClassLoader.getSystemResource()


Bryan Austad wrote:
> 
> I use a class with static methods to load properties.  getResource() does
> not return a static URL, so I cannot use it within my static method.
> getSystemResource() returns a static URL.
> 

 static URL?

 Do you mean that getSystemResource() is a static method in
ClassLoader? That's true, but you're allowed to call non-static
methods on other objects inside a static method. In fact,
getSystemResource() just gets the system classloader with
getSystemClassLoader() and calls getResource() on it.

 Where are you calling the static methods from? From the init()
of a servlet? If so, you can get the servlet's classloader and
pass it to the static method.


-- 
Christopher St. John cks@distributopia.com
DistribuTopia http://www.distributopia.com

--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>

--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


Mime
View raw message