Fetching parms form web.xml - I
4 October 2008The file named web.xml is part of your web applications. You may use it for different purpose. Sometimes you wish to define some parameters for your web application in it. Obviously, you need to use this in your application. I will briefly tell you how to do this.
At first, let me give you an example. We have a web application that needs to send its id and license code to some authentication server before doing some business operation. The id and license code are static and you may wish to define these as static final in your code:
public static final String appId = "dublin14"; public static final String license = "3KK838483";
Well, it will work but this info might change in future. Also assume that the web application will be deployed at different locations with different appId and license info. Its better to define these in some config file. The ideal choice will be web.xml
<web-app> <display-name>testwebapp</display-name> <context-param> <param-name>appId</param-name> <param-value> dublin14</param-value> </context-param> <context-param> <param-name>license</param-name> <param-value> 3KK838483</param-value> </context-param> </web-app>
Continued…
Related Posts:
Top Of Page | Trackback
If you found this page useful, consider linking to it. Simply copy and paste the code below into your web site.
It will look like this: Fetching parms form web.xml - I