Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can non-servlet class access web.xml

Status
Not open for further replies.

chunbo

Programmer
Jan 9, 2003
16
0
0
US
Can non-servlet class (helper class) access web.xml recource?

In my project, a servlet invoke another helper class, which needs to extract information from web.xml's context-param.
The helper class extends a class which provides all the db connection information. To make deployment easier, I want to move all the DB connection information to web.xml, but how to make web.xml accessable to a non-servlet class?

Thanks
 
If you put the parameters you need within the <init-param> tags in web.xml, and then load them in the servlet's init() method using the ServletConfig class method getInitParameter(). These can then be made available as and when other classes need them.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top