Chapter 30 Creating JavaMail


Deploying a JavaMail-enabled Web application

The J2EE specification allows you to group related Web content, EJBs, servlets, and JSPs into a Web application. A Web application is a package that can be easily deployed to any J2EE-compliant server. A Web application includes a deployment descriptor that describes how its various components should be configured on the host server.

When developing an application that includes JavaMail functionality, you must use JNDI to obtain mail sessions, as described in "Creating a JavaMail session". The use of logical names allows your application to run in environments where the JNDI namespace does not match the names hardcoded in your application. When you deploy the application, you map the logical names to actual names that match the server's configuration. You must catalog the JNDI names used by your code in the application's deployment descriptor. Once your JavaMail-enabled Web application is deployed to a host server, you must configure the javax.mail.Session resource factory reference to the name of the local mail server for that server.

Steps To define the local mail server for a JavaMail program:

  1. In Jaguar Manager, open the Properties dialog for the Web application that includes the servlet, EJB, or application that contains the JavaMail program.

  2. Select the Resource Refs tab.

  3. Click Add to add a row to the table.

  4. Select javax.mail.Session from the dropdown list in the Type column.

  5. The resource reference name in the Name column should be the logical name that refers to the JavaMail resource object and is hardcoded in the JavaMail code. For example, Mail.

  6. In the Deployment Settings field, type in the name of your local SMTP mail server for outgoing mail.

  7. Provide a description of your JavaMail resource in the Description field.

  8. Click OK.


 


Copyright © 2000 Sybase, Inc. All rights reserved.