tomcat7 - "lookup-name" of JNDI entry in tomcat -


i have few applications use jndi properties configured in web.xml:

<env-entry>     <env-entry-name>application1/username</env-entry-name>     <env-entry-type>java.lang.string</env-entry-type>     <env-entry-value>admin3</env-entry-value>     <lookup-name>username</lookup-name> </env-entry> 

i cannot entry lookup name, following code returns null:

string jndivalue = jndivalue = ((context) new initialcontext().lookup("java:comp/env")).lookup("username").tostring(); 

it seems tomcat not support attribute, right?

application1/username

so partial name application1/username.

string jndivalue = jndivalue = ((context) new initialcontext().lookup("java:comp/env")).lookup("username").tostring();

so looking partial name username.

you can simplify well. don't need nested context, or 2 context leaks, or tostring() part either:

context initialcontext = new initialcontext(); string jndivalue = jndivalue = initialcontext.lookup("java:comp/env/application1/username"); initialcontext.close(); 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -