| Author |
How to initialize a value in web.xml from a JNDI variable?
|
Veera Sundar
Greenhorn
Joined: Jun 08, 2007
Posts: 25
|
|
Hi All,
In my Java web application, the NTLM domain controller name is specified in web.xml like this:
In the above XML, we've hard-coded the domain controller name (DCNAME) in the param-value tag.
Now, is it possible to read this 'DCNAME' from a JNDI variable, instead of hard-coding it in web.xml file?
thanks in advance
|
Thanks,<br />Veera |<a href="http://veerasundar.com/blog" target="_blank" rel="nofollow">Blog</a>
|
 |
Anand Kumar Singh
Greenhorn
Joined: Oct 18, 2007
Posts: 22
|
|
Tomcat 5 provides a JNDI InitialContext implementation instance for each web application running under it.
The J2EE standard provides a standard set of elements in the /WEB-INF/web.xml file to reference resources; resources referenced in these elements must be defined in an application-server-specific configuration.
For Tomcat 5, these entries in per-web-application InitialContext are configured in the <Context> elements that can be specified in either $CATALINA_HOME/conf/server.xml or, preferably, the per-web-application context XML file (either META-INF/context.xml).
You can to define an environment resource like this:
<Environment name="myEnvName" value="whatever"
type="java.lang.String" override="false"/>
and then read it from java code:
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
String myEnvName = (String) envCtx .lookup("myEnvName");
For more info go to http://tomcat.apache.org/tomcat-5.5-doc/jndi-resources-howto.html
|
SCJP 5, SCWCD 5, SCBCD 5,
SCEA 5,
OCUP Fundamental,
OCUP Intermediate,
OCUP Advanced,
IBM Certified Solution Designer - Object Oriented Analysis and Design, vUML 2
|
 |
Vivek Kr Singh
Ranch Hand
Joined: Oct 12, 2007
Posts: 56
|
|
Good luck with JCIFS. We had a tough time with it.
Using context.xml per application is always preferred against setting values in tomcat config. However tomcat will make a copy of context.xml which will be cached in server "work" directory as <application-name>.xml. If the changes that you do in context.xml are not reflected immediately, consider deleting the cached file.
|
SCJP 1.4
|
 |
 |
|
|
subject: How to initialize a value in web.xml from a JNDI variable?
|
|
|