users@glassfish.java.net

Re: Where to place the properties file?

From: Cheng Fang <Cheng.Fang_at_Sun.COM>
Date: Mon, 22 Oct 2007 17:04:24 -0400

Put it in the same place as the referencing class.

WEB-INF/classes/com/foo/web/AServlet.class
WEB-INF/classes/com/foo/web/db.properties

-cheng

glassfish_at_javadesktop.org wrote:
> I am use the Netbeans (5.5.1) to do the exercise.
>
> I set some config information into a properties file, such as "db.properties" as below
>
> dbuser=username
> dbpass=password
>
> and place it to /web/ folder. In a class, I used code:
>
> Properties dbprop = new Properties();
> dbprop.load(this.getClass().getResourceAsStream("db.properties"));
>
> StringBuffer dsb = new StringBuffer();
> dsb.append(dbprop.getProperty("dbuser"));
> dsb.append(dbprop.getProperty("dbpass"));
>
> When use the app, it came up error for the line of
> dbprop.load(this.getClass().getResourceAsStream("db.properties"));
>
> Where should the "db.properties: to be placed?
> [Message sent by forum member 'kingsz1' (kingsz1)]
>
> http://forums.java.net/jive/thread.jspa?messageID=241568
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>