0N/AThis demo illustrates the use of JavaMail APIs in a 3-tiered web
0N/Aapplication. It must be deployed on a web server that supports
0N/Aservlet and JSP-based web applications (
e.g. Tomcat) using at least
0N/AJ2SE 1.3 and Servlet 2.2.
0N/A +-----------+ +-----------+ +-----------+
0N/A | Server |<-IMAP->| JavaMail |<-HTTP->| WWW |
0N/A +-----------+ | Web app |--HTML->| Browser |
0N/A | SMTP |<-SMTP->| | | |
0N/A +-----------+ +-----------+ +-----------+
0N/AThe JavaMail Web application supports the following functionality:
0N/A * login to an IMAP server
0N/A * list all the messages in the INBOX folder
0N/A * view the selected message
0N/A * compose and send a message
0N/AIt is comprised of an HTML document and several Web components
0N/A(servlets, JSP pages and custom tags) and is packaged in a Web
0N/Aarchive with the following contents:
0N/AThe collection of .html and .jsp files provide the client-side view
0N/Aof the JavaMail Web application.
0N/Adescriptor. It is an XML document that contains configuration and
0N/Adeployment information for the application.
0N/Acontains servlet and utility classes used by the web application.
0N/AThe FilterServlet acts as the Controller of the JavaMail Web
0N/Aapplication. All requests are mapped to this servlet. It checks
0N/Ato see that the user is logged in to the server before forwarding the
0N/Arequest to the appropriate JSP page. The AttachmentServlet is used
0N/Ato render non-text attachments and the MailUserBean is a utility class
0N/Aused to maintain information about the mail user.
0N/Acontains the Java archive file for the javamail custom tag library.
0N/AThe follow tags are furnished in the javamail tag library:
0N/A mailuser="mailuserbean"
0N/A [host="hostname"] [port="port"]
0N/A sender="email address" recipient="email address"
0N/A [cc="email address"] [bcc="email address"] [subject="subject"]>
0N/ADescription: Used to send messages.
0N/A<javamail:message id="messageinfo"
0N/A num="message number"/>
0N/ADescription: Used to read a single message.
0N/A<javamail:listmessages id="mailinfobean"
0N/A</javamail:listmessages>
0N/ADescription: Used to iterate through list of messages. The body of the
0N/Atag is repeated for each message in the list.
0N/ABuilding and Packaging the JavaMail Web application
0N/AAll source for this demo can be found in the following directories:
0N/Apackaging the demo. Before executing the build scripts, be sure that
0N/Athe following are in your CLASSPATH:
0N/AThe following steps are performed when building and packaging the demo.
0N/A5. Create an archive (
jtl.jar) of the taglib classes and add it
0N/A of its sub-directories).
0N/A(For a list of the contents of the resulting web archive,
0N/A see the beginning of this document.)
0N/AA note on sending mail
0N/AIn order to send mail using the JavaMail Web App, it is necessary to identify
0N/Aan SMTP host. This can be accomplished in a couple of ways.
0N/A1. Use the TOMCAT_OPTS environment variable.
0N/A Add the following to the TOMCAT_OPTS environment variable:
0N/A Restart your web server.
0N/A Add the following parameter to the <javamail:sendmail> tag:
0N/A host="yourSMTPmailservername"