Reputation: 99
Web.xml
<param-name>driver</param-name>
<param-value>com.mysql.jdbc.Driver</param-value>
</context-param>
<context-param>
<param-name>url</param-name>
<param-value>jdbc:mysql:///gts_user</param-value>
</context-param>
<context-param>
<param-name>user_name</param-name>
<param-value>root</param-value>
</context-param>
<context-param>
<param-name>password</param-name>
<param-value>gts</param-value>
</context-param>
i want get all value from web.xml using a java class file
Upvotes: 2
Views: 3091
Reputation: 279890
You'll be able to get access to all those context-param
elements if you have access to the ServletContext
. You have access to the ServletConfig
in a number of places, namely, Servlet#init(..)
, Filter#init(..)
, and most of the listener types.
The method you are looking for is ServletContext#getInitParameterNames()
.
Otherwise, you will have to parse the web.xml
yourself.
Upvotes: 2