Oops, sorry, WEB-INF is usually not accessible in your application
classpath, but through the ServletContext.

So you can access it with:
((WebApplication)WebApplication.get()).getServletContext().getResourceAsStream("/WEB-INF/conf/database.properties")

Xavier

On 9/1/07, Xavier Hanin <[EMAIL PROTECTED]> wrote:
>
> This is not really related to wicket, since your properties file is
> available in your classpath, you should be able to get it as a resource.
> Something like:
> Properties props=new Properties () ;
> props.load (
> getClass().getResourceAsStream("/WEB-INF/conf/database.properties") ) ;
>
> If you're in a static method of class initializer, you'll need to refer to
> the class using MyClass.class before the getResourceAsStream(). Note that
> you can actually use any Class object, since the path to the resource is
> absolute (starting with a slash).
>
> HTH,
>
> Xavier
> On 9/1/07, Edi <[EMAIL PROTECTED]> wrote:
> >
> >
> > Hello,
> >
> > I have one sample project named as TMS, In my "WEB-INF/conf" foler
> > contains
> > database.properties file. It contains
> >
> > e.g
> > hostname = some host name
> > url= some url
> >
> > This project contains only one database.properties file.
> > In java file, I want to get hostname and url from that property file.
> >
> > e.g.
> >
> > Properties props=new Properties () ;
> > props.load ( new FileInputStream ( new File
> > ("E:\\Workspace\\TMS\\WebRoot\\WEB-INF\\conf\\database.properties"))) ;
> >
> > String host= "hostname";
> > String val = props.getProperty ("Host Name Is :"+ host ) ;
> >
> > Using the above code, I have got both hostname and url.
> >
> > But my problem is, How to get the current project database.propertiesfile
> > path.
> >
> > Because in the above path name is hard coded.
> >
> > So How we get current project database.properties file path?
> >
> > Thanking you.
> >
> > --------------------
> >
> > Thank You
> > Edward
> > --
> > View this message in context:
> > http://www.nabble.com/How-to-get-path-name--tf4363832.html#a12438194
> > Sent from the Wicket - User mailing list archive at Nabble.com.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> --
> Xavier Hanin - Independent Java Consultant
> http://xhab.blogspot.com/
> http://incubator.apache.org/ivy/
> http://www.xoocode.org/




-- 
Xavier Hanin - Independent Java Consultant
http://xhab.blogspot.com/
http://incubator.apache.org/ivy/
http://www.xoocode.org/

Reply via email to