Resource References

References

To be platform independent, an application should refer to resources within the operating environment in which it is deployed, rather than having a specific location coded within the application. The J2EE specification defines a mechanism for an application to obtain resource references in its deployed environment. Resource references are used to obtain database connections, JavaMail sessions, URL factories, and JMS connection factories.

Table 12-8: Resource reference properties for a JSP target

Setting

Value

Name

Specify the JNDI name used to refer to a resource. Use the prefix mail/ for JavaMail references, jdbc/ for data source references, url/ for java.net.URL references, and jms/ for javax.jms references. For example, if your code refers to java:comp/env/jdbc/MyDatabase, enter jdbc/MyDatabase.

Type

Use one of these resources:

  • javax.sql.DataSource for JDBC connections

  • java.net.URL for URL factories

  • javax.mail.Session for mail sessions

  • javax.jms.QueueConnectionFactory for a JMS queue

  • javax.jms.TopicConnectionFactory for a JMS topic

Authentication

Enter:

  • Container if the container signs on to the resource manager on behalf of the servlet component. The methodology used to sign on is server specific.

  • Application if the application signs on programmatically to the resource manager.

  • Servlet if the servlet (not the container) signs on programmatically to the resource manager.

Sharing Scope

By default, connections to a resource manager can be shared by other components that use the resource in the same transaction context, optimizing the use of connections. Select Unshareable if the application cannot share connections to the resource.

Description

(Optional) A comment to explain how the property is used.

Environment references

Resource environment references allow the JSP page to use logical names to refer to administered objects associated with resources. These references must be bound to administered objects in the deployment environment.

Table 12-9: Environment reference properties for a JSP target

Setting

Value

Name

Specify a name for a reference to an administered object associated with resources, such as a JMS message queue. The name is relative to the java:comp/env context, for example, jms/MyQueue.

Type

Specify the type of the resource, for example, javax.jms.Queue.

Description

(Optional) A comment to explain how the property is used.