This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes what's the use of InitialContext? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "what Watch "what New topic
Author

what's the use of InitialContext?

Viv Gupta
Greenhorn

Joined: Dec 01, 2005
Posts: 15
Hi All,

I want to know what's the use of InitialContext? what happens when we write

ujjwal soni
Ranch Hand

Joined: Mar 28, 2007
Posts: 403
The javax.naming.InitialContext class implements the Context interface and serves as our entry point to a naming system. To use JNDI to access objects in a naming system, you must first create an InitialContextobject. The InitialContext constructor takes a set of properties, in the form of a java.util.Hashtable or one of its subclasses, such as a Properties object. Here is how we created an InitialContext in the Lookup example:

Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.fscontext.RefFSContextFactory");
props.put(Context.PROVIDER_URL, "file:///");

// Create the initial context from the properties we just created
Context initialContext = new InitialContext(props);


Regards,

Ujjwal Soni


Cheers!!!
Ujjwal B Soni <baroda, gujarat, india> <+919909981973>
"Helping hands are better than praying lips......"
Lave Kulshreshtha
Ranch Hand

Joined: Oct 21, 2007
Posts: 106
Refer to http://java.sun.com/j2se/1.3/docs/api/javax/naming/InitialContext.html

-Lave


SCJP 1.4, SCWCD 1.4, SCBCD 1.3, ITIL V3 Foundation Certification
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what's the use of InitialContext?
 
Similar Threads
InitialContext vs ServletContext
How to configure JSP for use @EJB annotation?
Why can't I invoke a ejb in Tomcat?
New to EJB: ClassCastException on EJB Local Home
Difference between getting Connection directly from the pool or from a DataSource