Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about default constructor for InitialContext()...

 
SAFROLE YUTANI
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If an application server is listening on port 7001, and lets say a servlet running on the app server wants to find a resource in the app server using JNDI, is it possible to use an InitialContext object without initializing it with the CONTEXT_FACTORY ans PROVIDER_URL parameters?
Can I just use:
InitialContext()
...instead of:
InitialContext ctx = null;
Hashtable h = new Hashtable();
h.put( Context.INITIAL_CONTEXT_FACTORY, "factoryname");
h.put( Context.PROVIDER_URL, "url");
InitialContext( h);
SAF
 
SAFROLE YUTANI
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Forget it. I ran a small driver and tested this out myself. It seems that InitialContext() without any initialization paramter always defaults to the local machine, and it also finds the listening port of the application server by some sort of magic I'm assuming .
SAF
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic