• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to initialize a value in web.xml from a JNDI variable?

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic