• 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

Where to configure global variable in Tomcat

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm sure this will end up being a stoopid mistake on my part but...

I'm trying to get the following code to return a non-null value:

context = new InitialContext();
value = (String) context.lookup("myDefinedKey");

Where must I define "myDefinedKey" so it is available from any servlet? I tried in the web.xml, the server.xml and the context.xml but either I'm not putting the information in the correctl location, or I'm not defining it correctly.

Can anyone help?

Thanks,

L
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In context XML, to define type/value and assign a name:


However, your main problem is failure to provide the right context for the JNDI lookup. For the above example, you'd look up the value under "java:comp/env/serverUrl".
 
L Duperval
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:In context XML, to define type/value and assign a name:



Ok, thanks I'll try that but I think it is part of my unsuccessful attempts. I'll double check.

However, your main problem is failure to provide the right context for the JNDI lookup. For the above example, you'd look up the value under "java:comp/env/serverUrl".



What do you mean by that? The code I use works in Websphere and finds the correct values, as I defined them trough WS's admin console.

If I understand you correctly, it's non-portable and won't work like that in Tomcat, for example, because I'm missing come contextual information which seems to be provided automatically by Websphere.

L
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic