you may want to try ServletContext.getResourceAsStream()

getServletContext().getResourceAsStream("/WEB-INF/classes/myprop.properties"
);

Charlie

> -----Original Message-----
> From: Klein, Scott @ TW [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, November 19, 2002 7:37 PM
> To: 'Tomcat Users List'
> Subject: RE: Loading properties file for an external class
> 
> 
> Well, I have no idea why - but I switched to using a 
> ResourceBundle and it
> worked. 
> 
> It doesn't seem like it should matter - except for how a 
> bundle obtains its
> class loader.
> 
> If anyone has some insight into _why_ this fixed the problem....
> 
> In the meantime, thanks for the help!
> 
> 
> 
> scott
> 
> -----Original Message-----
> From: David Wall [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, November 19, 2002 4:26 PM
> To: Tomcat Users List
> Subject: Re: Loading properties file for an external class
> 
> 
> > JSP page:
> > <%@ page import="my.pkg.Class" %>
> >
> > Class source:
> >         try {
> >             InputStream is =
> > this.getClass().getResourceAsStream(File.separatorChar +
> "Prop.properties");
> >             this.props.load(is);
> >         } catch( Throwable t ) {
> >         }
> 
> Not sure about this method since we just use ResourceBundle 
> and it does all
> of the classpath searching for us:
> 
>        try
>         {
>             // if you put Prop.properties in your base
> WEB-INF/classes/Prop.properties
>             java.util.ResouceBundle bundle =
> java.util.ResourceBundle.getBundle("Prop"); // the 
> .properties is assumed
> 
>             // or if you put Prop.properties in a package name:
> WEB-INF/classes/com/host/config/Prop.properties
>             java.util.ResouceBundle bundle =
> java.util.ResourceBundle.getBundle("com.host.config.Prop"); // the
> .properties is assumed
>             java.util.Enumeration keys = bundle.getKeys();
> 
>             String oneProp = bundle.getString("oneprop");
>         }
>         catch( java.util.MissingResourceException e )
>         {
>             String msg = "PropertiesFile - Could not load 
> properties file '"
> + bundleName + "': " + e.getMessage();
>             throw e;
>         }
> 
> 
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> 
> --
> To unsubscribe, e-mail:   
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

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

Reply via email to