property file

1 view
Skip to first unread message

Ashish Rana

unread,
Apr 4, 2010, 12:21:46 AM4/4/10
to open-traini...@googlegroups.com
how to use property file for database connection in web application?


i have desktop application but i am not able to run web application using property file.

Ritesh Suthar

unread,
Apr 4, 2010, 3:25:49 AM4/4/10
to open-traini...@googlegroups.com
Hi Ashish,

As you need to read property file in web application, upfront i can suggest you two aternative

Approach 1. Place your property file in web-inf directory, read the property file in the servlet wherein you can specify path of the property file in the servlet init parameter while registering the servlet in web.xml

Approach 2. Place your property file visible in the web application classpath (e.g. web-inf/classes location). You can easily read the property file by using following api in the Utility class where a Utility class is also at the same level

this.getClass().getClassLoader().getResourceAsStream(<Name of your properties file>) 

explore some of the examples that how to use above API.

Regards,
Ritesh

You can parameterize the property file in the servlet 

On Sun, Apr 4, 2010 at 9:51 AM, Ashish Rana <ashis...@gmail.com> wrote:
how to use property file for database connection in web application?


i have desktop application but i am not able to run web application using property file.

--
You received this message because you are subscribed to the Google
Groups "open-training-community" group.
To post to this group, send email to
open-traini...@googlegroups.com
To unsubscribe from this group, send email to
open-training-com...@googlegroups.com
For more options, visit this group at
http://groups.google.co.in/group/open-training-community?hl=en-GB



--
Regards,
Ritesh
Cell: +919925151637
Reply all
Reply to author
Forward
0 new messages