February 25, 2021
Hot Topics:

Locating Resources Using JNDI (Java Naming and Directory Interface)

  • By Sams Publishing
  • Send Email »
  • More Articles »


A naming service provides a means of storing simple information under a name, so that by specifying the registered name you can retrieve the information. A directory service is similar to a naming service except that it additionally allows attributes to be associated with the stored objects. Directory services use the attributes to categorize names, which means that powerful searching of the directory tree structure can be supported.

JNDI provides a uniform API into a naming or directory service. You can use any naming or directory service through JNDI as long as you have access to a Service Provider implementation for that service.

It is simple to use JNDI from any Java program, including Web applications.

The most common uses of JNDI in Web applications are to publish objects such as

  • Databases (called data sources). You will see this in Chapter 14, "Databases and JSP."

  • Enterprise JavaBeans (EJBs). See Chapter 15, "JSP and EJB interaction," for details.

  • JMS message queues and topics.

About the Authors

The authors of this book work for Content Master Ltd., a technical authoring company in the United Kingdom specializing in the production of training and educational materials. For more information on Content Master, please see its Web site at www.contentmaster.com.

Nick Todd B.Sc. PGCE has been with Content Master since 2000 and has been working in technical education since 1997. Prior to that, he was a Web designer, the lead developer on a Web site for a British university, and he also worked on a Web site for British Telecom. Nick has wide experience in providing training and consulting in Java, XML, and Internet technology to companies such as Sun Microsystems, Art Technology Group, Stilo Technology, and the UK eScience Institute based at Edinburgh University. In conjunction with Content Master, Nick has also written courses on Java technology for the Sun Microsystems global curriculum and also courseware on Web-related technology for Microsoft. When Nick is not sitting in front of a computer or standing in front of a technical class, you will often find him working in the Christian church that he leads in Bristol, England.

Mark Szolkowski, M.Eng was born in Manchester, England in 1972, and has a Masters degree in Microelectronic Systems Engineering. During his four years at UMIST, he spent the summers learning the wonders of writing 16-bit Windows software in C using nothing more than M and a command-line compiler. After leaving university, Mark worked as a System Administrator at a software house, which allowed him to feed his programming habit. Since 2000, Mark has mostly worked as an independent technical trainer and author, specializing in Java and XML technologies. Mark has been working with Content Master since 2001.

Source of this Material

This material is from Chapter 13, Locating Resources Using JNDI, from the book JavaServer Pages Developer's Handbook (ISBN: 0-672-32438-5) written by Nick Todd and Mark Szolkowski, published by Sams Publishing. .

To access the full Table of Contents for the book

Other Chapters from Sams Publishing:

Web Services and Flows (WSFL)
Overview of JXTA
Introduction to EJBs
Processing Speech with Java
P2P Dynamic Networks
XP and Ant

Page 7 of 7

This article was originally published on June 2, 2003

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date