0N/A/*
364N/A * Copyright (c) 1998-2011 Oracle and/or its affiliates. All rights reserved.
0N/A *
0N/A * Redistribution and use in source and binary forms, with or without
0N/A * modification, are permitted provided that the following conditions
0N/A * are met:
0N/A *
0N/A * - Redistributions of source code must retain the above copyright
0N/A * notice, this list of conditions and the following disclaimer.
0N/A *
0N/A * - Redistributions in binary form must reproduce the above copyright
0N/A * notice, this list of conditions and the following disclaimer in the
0N/A * documentation and/or other materials provided with the distribution.
0N/A *
292N/A * - Neither the name of Oracle nor the names of its
0N/A * contributors may be used to endorse or promote products derived
0N/A * from this software without specific prior written permission.
0N/A *
0N/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
0N/A * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
0N/A * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
0N/A * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
0N/A * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
0N/A * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
0N/A * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
0N/A * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
0N/A * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
0N/A * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
0N/A * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0N/A */
0N/A
0N/Aimport java.io.*;
0N/Aimport java.util.*;
0N/Aimport java.text.*;
0N/A
0N/Aimport javax.servlet.*;
0N/Aimport javax.servlet.http.*;
0N/Aimport javax.mail.*;
318N/Aimport javax.mail.Part;
0N/Aimport javax.mail.internet.*;
0N/Aimport javax.activation.*;
0N/A
0N/A
0N/A/**
0N/A * This is a servlet that demonstrates the use of JavaMail APIs
0N/A * in a 3-tier application. It allows the user to login to an
0N/A * IMAP store, list all the messages in the INBOX folder, view
0N/A * selected messages, compose and send a message, and logout.
0N/A * <p>
0N/A * Please note: This is NOT an example of how to write servlets!
0N/A * This is simply to show that JavaMail can be used in a servlet.
0N/A * <p>
0N/A * For more information on this servlet, see the
0N/A * JavaMailServlet.README.txt file.
0N/A * <p>
0N/A * For more information on servlets, see
0N/A * <a href="http://java.sun.com/products/java-server/servlets/index.html">
0N/A * http://java.sun.com/products/java-server/servlets/index.html</a>
0N/A *
0N/A * @author Max Spivak
0N/A */
0N/Apublic class JavaMailServlet extends HttpServlet implements SingleThreadModel {
0N/A String protocol = "imap";
0N/A String mbox = "INBOX";
0N/A
0N/A
0N/A /**
0N/A * This method handles the "POST" submission from two forms: the
0N/A * login form and the message compose form. The login form has the
0N/A * following parameters: <code>hostname</code>, <code>username</code>,
0N/A * and <code>password</code>. The <code>send</code> parameter denotes
0N/A * that the method is processing the compose form submission.
0N/A */
0N/A public void doPost(HttpServletRequest req, HttpServletResponse res)
0N/A throws ServletException, IOException {
0N/A
29N/A // get the session
0N/A HttpSession ssn = req.getSession(true);
0N/A
0N/A String send = req.getParameter("send");
29N/A String host = req.getParameter("hostname");
29N/A String user = req.getParameter("username");
29N/A String passwd = req.getParameter("password");
29N/A URLName url = new URLName(protocol, host, -1, mbox, user, passwd);
0N/A
29N/A ServletOutputStream out = res.getOutputStream();
0N/A res.setContentType("text/html");
0N/A out.println("<html><body bgcolor=\"#CCCCFF\">");
0N/A
0N/A if (send != null) {
0N/A // process message sending
0N/A send(req, res, out, ssn);
0N/A
0N/A } else {
0N/A // initial login
0N/A
0N/A // create
0N/A MailUserData mud = new MailUserData(url);
0N/A ssn.putValue("javamailservlet", mud);
0N/A
0N/A try {
0N/A Properties props = System.getProperties();
0N/A props.put("mail.smtp.host", host);
0N/A Session session = Session.getDefaultInstance(props, null);
0N/A session.setDebug(false);
0N/A Store store = session.getStore(url);
0N/A store.connect();
0N/A Folder folder = store.getDefaultFolder();
0N/A if (folder == null)
0N/A throw new MessagingException("No default folder");
0N/A
0N/A folder = folder.getFolder(mbox);
0N/A if (folder == null)
0N/A throw new MessagingException("Invalid folder");
0N/A
0N/A folder.open(Folder.READ_WRITE);
0N/A int totalMessages = folder.getMessageCount();
0N/A Message[] msgs = folder.getMessages();
0N/A FetchProfile fp = new FetchProfile();
0N/A fp.add(FetchProfile.Item.ENVELOPE);
0N/A folder.fetch(msgs, fp);
0N/A
0N/A // track who logged in
0N/A System.out.println("Login from: " + store.getURLName());
0N/A
0N/A // save stuff into MUD
0N/A mud.setSession(session);
0N/A mud.setStore(store);
0N/A mud.setFolder(folder);
0N/A
0N/A // splash
0N/A out.print("<center>");
0N/A out.print("<font face=\"Arial,Helvetica\" font size=+3>");
0N/A out.println("<b>Welcome to JavaMail!</b></font></center><p>");
0N/A
0N/A // folder table
0N/A out.println("<table width=\"50%\" border=0 align=center>");
0N/A // folder name column header
0N/A out.print("<tr><td width=\"75%\" bgcolor=\"#ffffcc\">");
0N/A out.print("<font face=\"Arial,Helvetica\" font size=-1>");
0N/A out.println("<b>FolderName</b></font></td><br>");
0N/A // msg count column header
0N/A out.print("<td width=\"25%\" bgcolor=\"#ffffcc\">");
0N/A out.print("<font face=\"Arial,Helvetica\" font size=-1>");
0N/A out.println("<b>Messages</b></font></td><br>");
0N/A out.println("</tr>");
0N/A // folder name
0N/A out.print("<tr><td width=\"75%\" bgcolor=\"#ffffff\">");
0N/A out.print("<a href=\"" + HttpUtils.getRequestURL(req) + "\">" +
0N/A "Inbox" + "</a></td><br>");
0N/A // msg count
0N/A out.println("<td width=\"25%\" bgcolor=\"#ffffff\">" +
0N/A totalMessages + "</td>");
0N/A out.println("</tr>");
0N/A out.println("</table");
0N/A } catch (Exception ex) {
0N/A out.println(ex.toString());
0N/A } finally {
0N/A out.println("</body></html>");
0N/A out.close();
0N/A }
0N/A }
0N/A }
0N/A
0N/A
0N/A /**
0N/A * This method handles the GET requests for the client.
0N/A */
0N/A public void doGet (HttpServletRequest req, HttpServletResponse res)
0N/A throws ServletException, IOException {
0N/A
29N/A HttpSession ses = req.getSession(false); // before we write to out
29N/A ServletOutputStream out = res.getOutputStream();
0N/A MailUserData mud = getMUD(ses);
0N/A
0N/A if (mud == null) {
0N/A res.setContentType("text/html");
0N/A out.println("<html><body>Please Login (no session)</body></html>");
0N/A out.close();
0N/A return;
0N/A }
0N/A
0N/A if (!mud.getStore().isConnected()) {
0N/A res.setContentType("text/html");
0N/A out.println("<html><body>Not Connected To Store</body></html>");
0N/A out.close();
0N/A return;
0N/A }
0N/A
0N/A
0N/A // mux that takes a GET request, based on parameters figures
0N/A // out what it should do, and routes it to the
0N/A // appropriate method
0N/A
0N/A // get url parameters
0N/A String msgStr = req.getParameter("message");
29N/A String logout = req.getParameter("logout");
0N/A String compose = req.getParameter("compose");
0N/A String part = req.getParameter("part");
0N/A int msgNum = -1;
0N/A int partNum = -1;
0N/A
0N/A // process url params
0N/A if (msgStr != null) {
0N/A // operate on message "msgStr"
0N/A msgNum = Integer.parseInt(msgStr);
0N/A
0N/A if (part == null) {
0N/A // display message "msgStr"
29N/A res.setContentType("text/html");
0N/A displayMessage(mud, req, out, msgNum);
0N/A
364N/A } else {
0N/A // display part "part" in message "msgStr"
0N/A partNum = Integer.parseInt(part);
29N/A displayPart(mud, msgNum, partNum, out, res);
0N/A }
0N/A
0N/A } else if (compose != null) {
0N/A // display compose form
0N/A compose(mud, res, out);
0N/A
29N/A } else if (logout != null) {
0N/A // process logout
29N/A try {
29N/A mud.getFolder().close(false);
29N/A mud.getStore().close();
0N/A ses.invalidate();
29N/A out.println("<html><body>Logged out OK</body></html>");
29N/A } catch (MessagingException mex) {
29N/A out.println(mex.toString());
29N/A }
0N/A
0N/A } else {
0N/A // display headers
0N/A displayHeaders(mud, req, out);
0N/A }
0N/A }
0N/A
0N/A /* main method to display messages */
0N/A private void displayMessage(MailUserData mud, HttpServletRequest req,
0N/A ServletOutputStream out, int msgNum)
0N/A throws IOException {
0N/A
0N/A out.println("<html>");
29N/A out.println("<HEAD><TITLE>JavaMail Servlet</TITLE></HEAD>");
0N/A out.println("<BODY bgcolor=\"#ccccff\">");
0N/A out.print("<center><font face=\"Arial,Helvetica\" ");
0N/A out.println("font size=\"+3\"><b>");
0N/A out.println("Message " + (msgNum+1) + " in folder " +
0N/A mud.getStore().getURLName() +
0N/A "/INBOX</b></font></center><p>");
0N/A
0N/A try {
0N/A Message msg = mud.getFolder().getMessage(msgNum);
0N/A
0N/A // first, display this message's headers
0N/A displayMessageHeaders(mud, msg, out);
0N/A
0N/A // and now, handle the content
0N/A Object o = msg.getContent();
29N/A
0N/A //if (o instanceof String) {
0N/A if (msg.isMimeType("text/plain")) {
0N/A out.println("<pre>");
0N/A out.println((String)o);
0N/A out.println("</pre>");
0N/A //} else if (o instanceof Multipart){
0N/A } else if (msg.isMimeType("multipart/*")) {
0N/A Multipart mp = (Multipart)o;
0N/A int cnt = mp.getCount();
0N/A for (int i = 0; i < cnt; i++) {
0N/A displayPart(mud, msgNum, mp.getBodyPart(i), i, req, out);
0N/A }
0N/A } else {
0N/A out.println(msg.getContentType());
0N/A }
0N/A
0N/A } catch (MessagingException mex) {
0N/A out.println(mex.toString());
0N/A }
0N/A
0N/A out.println("</BODY></html>");
0N/A out.close();
0N/A }
0N/A
0N/A /**
0N/A * This method displays a message part. <code>text/plain</code>
0N/A * content parts are displayed inline. For all other parts,
0N/A * a URL is generated and displayed; clicking on the URL
0N/A * brings up the part in a separate page.
0N/A */
0N/A private void displayPart(MailUserData mud, int msgNum, Part part,
0N/A int partNum, HttpServletRequest req,
0N/A ServletOutputStream out)
0N/A throws IOException {
0N/A
0N/A if (partNum != 0)
0N/A out.println("<p><hr>");
0N/A
29N/A try {
0N/A
0N/A String sct = part.getContentType();
0N/A if (sct == null) {
0N/A out.println("invalid part");
0N/A return;
0N/A }
0N/A ContentType ct = new ContentType(sct);
0N/A
0N/A if (partNum != 0)
0N/A out.println("<b>Attachment Type:</b> " +
0N/A ct.getBaseType() + "<br>");
0N/A
0N/A if (ct.match("text/plain")) {
0N/A // display text/plain inline
0N/A out.println("<pre>");
0N/A out.println((String)part.getContent());
0N/A out.println("</pre>");
0N/A
0N/A } else {
0N/A // generate a url for this part
0N/A String s;
0N/A if ((s = part.getFileName()) != null)
0N/A out.println("<b>Filename:</b> " + s + "<br>");
0N/A s = null;
0N/A if ((s = part.getDescription()) != null)
0N/A out.println("<b>Description:</b> " + s + "<br>");
0N/A
0N/A out.println("<a href=\"" +
0N/A HttpUtils.getRequestURL(req) +
0N/A "?message=" +
0N/A msgNum + "&part=" +
0N/A partNum + "\">Display Attachment</a>");
0N/A }
0N/A } catch (MessagingException mex) {
0N/A out.println(mex.toString());
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * This method gets the stream from for a given msg part and
0N/A * pushes it out to the browser with the correct content type.
0N/A * Used to display attachments and relies on the browser's
0N/A * content handling capabilities.
0N/A */
0N/A private void displayPart(MailUserData mud, int msgNum,
0N/A int partNum, ServletOutputStream out,
0N/A HttpServletResponse res)
0N/A throws IOException {
0N/A
0N/A Part part = null;
0N/A
29N/A try {
0N/A Message msg = mud.getFolder().getMessage(msgNum);
0N/A
0N/A Multipart mp = (Multipart)msg.getContent();
0N/A part = mp.getBodyPart(partNum);
0N/A
0N/A String sct = part.getContentType();
0N/A if (sct == null) {
0N/A out.println("invalid part");
0N/A return;
0N/A }
0N/A ContentType ct = new ContentType(sct);
0N/A
0N/A res.setContentType(ct.getBaseType());
0N/A InputStream is = part.getInputStream();
0N/A int i;
0N/A while ((i = is.read()) != -1)
0N/A out.write(i);
0N/A out.flush();
0N/A out.close();
0N/A } catch (MessagingException mex) {
0N/A out.println(mex.toString());
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * This is a utility message that pretty-prints the message
0N/A * headers for message that is being displayed.
0N/A */
0N/A private void displayMessageHeaders(MailUserData mud, Message msg,
0N/A ServletOutputStream out)
0N/A throws IOException {
0N/A
0N/A try {
0N/A out.println("<b>Date:</b> " + msg.getSentDate() + "<br>");
0N/A
29N/A Address[] fr = msg.getFrom();
29N/A if (fr != null) {
29N/A boolean tf = true;
29N/A out.print("<b>From:</b> ");
29N/A for (int i = 0; i < fr.length; i++) {
29N/A out.print(((tf) ? " " : ", ") + getDisplayAddress(fr[i]));
29N/A tf = false;
29N/A }
29N/A out.println("<br>");
29N/A }
0N/A
29N/A Address[] to = msg.getRecipients(Message.RecipientType.TO);
29N/A if (to != null) {
29N/A boolean tf = true;
29N/A out.print("<b>To:</b> ");
29N/A for (int i = 0; i < to.length; i++) {
29N/A out.print(((tf) ? " " : ", ") + getDisplayAddress(to[i]));
29N/A tf = false;
29N/A }
29N/A out.println("<br>");
29N/A }
0N/A
29N/A Address[] cc = msg.getRecipients(Message.RecipientType.CC);
29N/A if (cc != null) {
29N/A boolean cf = true;
29N/A out.print("<b>CC:</b> ");
29N/A for (int i = 0; i < cc.length; i++) {
29N/A out.print(((cf) ? " " : ", ") + getDisplayAddress(cc[i]));
0N/A cf = false;
0N/A }
29N/A out.println("<br>");
29N/A }
29N/A
0N/A out.print("<b>Subject:</b> " +
0N/A ((msg.getSubject() !=null) ? msg.getSubject() : "") +
0N/A "<br>");
0N/A
29N/A } catch (MessagingException mex) {
0N/A out.println(msg.toString());
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * This method displays the URL's for the available commands and the
0N/A * INBOX headerlist
0N/A */
0N/A private void displayHeaders(MailUserData mud,
0N/A HttpServletRequest req,
29N/A ServletOutputStream out)
0N/A throws IOException {
0N/A
29N/A SimpleDateFormat df = new SimpleDateFormat("EE M/d/yy");
0N/A
29N/A out.println("<html>");
29N/A out.println("<HEAD><TITLE>JavaMail Servlet</TITLE></HEAD>");
0N/A out.println("<BODY bgcolor=\"#ccccff\"><hr>");
0N/A out.print("<center><font face=\"Arial,Helvetica\" font size=\"+3\">");
0N/A out.println("<b>Folder " + mud.getStore().getURLName() +
0N/A "/INBOX</b></font></center><p>");
0N/A
0N/A // URL's for the commands that are available
0N/A out.println("<font face=\"Arial,Helvetica\" font size=\"+3\"><b>");
29N/A out.println("<a href=\"" +
0N/A HttpUtils.getRequestURL(req) +
0N/A "?logout=true\">Logout</a>");
29N/A out.println("<a href=\"" +
0N/A HttpUtils.getRequestURL(req) +
0N/A "?compose=true\" target=\"compose\">Compose</a>");
0N/A out.println("</b></font>");
0N/A out.println("<hr>");
0N/A
0N/A // List headers in a table
29N/A out.print("<table cellpadding=1 cellspacing=1 "); // table
0N/A out.println("width=\"100%\" border=1>"); // settings
0N/A
0N/A // sender column header
0N/A out.println("<tr><td width=\"25%\" bgcolor=\"ffffcc\">");
0N/A out.println("<font face=\"Arial,Helvetica\" font size=\"+1\">");
0N/A out.println("<b>Sender</b></font></td>");
0N/A // date column header
0N/A out.println("<td width=\"15%\" bgcolor=\"ffffcc\">");
0N/A out.println("<font face=\"Arial,Helvetica\" font size=\"+1\">");
0N/A out.println("<b>Date</b></font></td>");
0N/A // subject column header
0N/A out.println("<td bgcolor=\"ffffcc\">");
0N/A out.println("<font face=\"Arial,Helvetica\" font size=\"+1\">");
0N/A out.println("<b>Subject</b></font></td></tr>");
0N/A
0N/A try {
0N/A Folder f = mud.getFolder();
0N/A int msgCount = f.getMessageCount();
0N/A Message m = null;
0N/A // for each message, show its headers
0N/A for (int i = 1; i <= msgCount; i++) {
29N/A m = f.getMessage(i);
0N/A
0N/A // if message has the DELETED flag set, don't display it
0N/A if (m.isSet(Flags.Flag.DELETED))
0N/A continue;
0N/A
0N/A // from
29N/A out.println("<tr valigh=middle>");
29N/A out.print("<td width=\"25%\" bgcolor=\"ffffff\">");
0N/A out.println("<font face=\"Arial,Helvetica\">" +
0N/A ((m.getFrom() != null) ?
29N/A m.getFrom()[0].toString() :
29N/A "" ) +
0N/A "</font></td>");
0N/A
0N/A // date
29N/A out.print("<td nowrap width=\"15%\" bgcolor=\"ffffff\">");
0N/A out.println("<font face=\"Arial,Helvetica\">" +
29N/A df.format((m.getSentDate()!=null) ?
0N/A m.getSentDate() : m.getReceivedDate()) +
0N/A "</font></td>");
0N/A
0N/A // subject & link
29N/A out.print("<td bgcolor=\"ffffff\">");
0N/A out.println("<font face=\"Arial,Helvetica\">" +
29N/A "<a href=\"" +
0N/A HttpUtils.getRequestURL(req) +
29N/A "?message=" +
29N/A i + "\">" +
29N/A ((m.getSubject() != null) ?
29N/A m.getSubject() :
29N/A "<i>No Subject</i>") +
29N/A "</a>" +
29N/A "</font></td>");
29N/A out.println("</tr>");
0N/A }
0N/A } catch (MessagingException mex) {
0N/A out.println("<tr><td>" + mex.toString() + "</td></tr>");
0N/A mex.printStackTrace();
0N/A }
0N/A
0N/A out.println("</table>");
0N/A out.println("</BODY></html>");
0N/A out.flush();
0N/A out.close();
0N/A }
0N/A
0N/A /**
0N/A * This method handles the request when the user hits the
0N/A * <i>Compose</i> link. It send the compose form to the browser.
0N/A */
0N/A private void compose(MailUserData mud, HttpServletResponse res,
0N/A ServletOutputStream out)
0N/A throws IOException {
0N/A
0N/A res.setContentType("text/html");
0N/A out.println(composeForm);
0N/A out.close();
0N/A }
0N/A
0N/A /**
0N/A * This method processes the send request from the compose form
0N/A */
0N/A private void send(HttpServletRequest req, HttpServletResponse res,
0N/A ServletOutputStream out, HttpSession ssn)
0N/A throws IOException {
0N/A
29N/A String to = req.getParameter("to");
0N/A String cc = req.getParameter("cc");
0N/A String subj = req.getParameter("subject");
0N/A String text = req.getParameter("text");
0N/A
0N/A try {
0N/A MailUserData mud = getMUD(ssn);
0N/A if (mud == null)
0N/A throw new Exception("trying to send, but not logged in");
0N/A
0N/A Message msg = new MimeMessage(mud.getSession());
0N/A InternetAddress[] toAddrs = null, ccAddrs = null;
0N/A
0N/A if (to != null) {
0N/A toAddrs = InternetAddress.parse(to, false);
0N/A msg.setRecipients(Message.RecipientType.TO, toAddrs);
0N/A } else
0N/A throw new MessagingException("No \"To\" address specified");
0N/A
0N/A if (cc != null) {
0N/A ccAddrs = InternetAddress.parse(cc, false);
0N/A msg.setRecipients(Message.RecipientType.CC, ccAddrs);
0N/A }
0N/A
0N/A if (subj != null)
0N/A msg.setSubject(subj);
0N/A
0N/A URLName u = mud.getURLName();
0N/A msg.setFrom(new InternetAddress(u.getUsername() + "@" +
0N/A u.getHost()));
0N/A
0N/A if (text != null)
0N/A msg.setText(text);
0N/A
0N/A Transport.send(msg);
0N/A
0N/A out.println("<h1>Message sent successfully</h1></body></html>");
0N/A out.close();
0N/A
0N/A } catch (Exception mex) {
0N/A out.println("<h1>Error sending message.</h1>");
0N/A out.println(mex.toString());
0N/A out.println("<br></body></html>");
0N/A }
0N/A }
0N/A
0N/A
0N/A // utility method; returns a string suitable for msg header display
0N/A private String getDisplayAddress(Address a) {
29N/A String pers = null;
29N/A String addr = null;
29N/A if (a instanceof InternetAddress &&
29N/A ((pers = ((InternetAddress)a).getPersonal()) != null)) {
0N/A
0N/A addr = pers + " "+"&lt;"+((InternetAddress)a).getAddress()+"&gt;";
29N/A } else
29N/A addr = a.toString();
29N/A
29N/A return addr;
0N/A }
0N/A
0N/A // utility method; retrieve the MailUserData
0N/A // from the HttpSession and return it
0N/A private MailUserData getMUD(HttpSession ses) throws IOException {
0N/A MailUserData mud = null;
0N/A
0N/A if (ses == null) {
0N/A return null;
0N/A } else {
0N/A if ((mud = (MailUserData)ses.getValue("javamailservlet")) == null){
0N/A return null;
0N/A }
0N/A }
0N/A return mud;
0N/A }
0N/A
0N/A
0N/A public String getServletInfo() {
29N/A return "A mail reader servlet";
0N/A }
0N/A
0N/A /**
0N/A * This is the HTML code for the compose form. Another option would
0N/A * have been to use a separate html page.
0N/A */
0N/A private static String composeForm = "<HTML><HEAD><TITLE>JavaMail Compose</TITLE></HEAD><BODY BGCOLOR=\"#CCCCFF\"><FORM ACTION=\"/servlet/JavaMailServlet\" METHOD=\"POST\"><input type=\"hidden\" name=\"send\" value=\"send\"><P ALIGN=\"CENTER\"><B><FONT SIZE=\"4\" FACE=\"Verdana, Arial, Helvetica\">JavaMail Compose Message</FONT></B><P><TABLE BORDER=\"0\" WIDTH=\"100%\"><TR><TD WIDTH=\"16%\" HEIGHT=\"22\"> <P ALIGN=\"RIGHT\"><B><FONT FACE=\"Verdana, Arial, Helvetica\">To:</FONT></B></TD><TD WIDTH=\"84%\" HEIGHT=\"22\"><INPUT TYPE=\"TEXT\" NAME=\"to\" SIZE=\"30\"> <FONT SIZE=\"1\" FACE=\"Verdana, Arial, Helvetica\"> (separate addresses with commas)</FONT></TD></TR><TR><TD WIDTH=\"16%\"><P ALIGN=\"RIGHT\"><B><FONT FACE=\"Verdana, Arial, Helvetica\">CC:</FONT></B></TD><TD WIDTH=\"84%\"><INPUT TYPE=\"TEXT\" NAME=\"cc\" SIZE=\"30\"> <FONT SIZE=\"1\" FACE=\"Verdana, Arial, Helvetica\"> (separate addresses with commas)</FONT></TD></TR><TR><TD WIDTH=\"16%\"><P ALIGN=\"RIGHT\"><B><FONT FACE=\"Verdana, Arial, Helvetica\">Subject:</FONT></B></TD><TD WIDTH=\"84%\"><INPUT TYPE=\"TEXT\" NAME=\"subject\" SIZE=\"55\"></TD></TR><TR><TD WIDTH=\"16%\">&nbsp;</TD><TD WIDTH=\"84%\"><TEXTAREA NAME=\"text\" ROWS=\"15\" COLS=\"53\"></TEXTAREA></TD></TR><TR><TD WIDTH=\"16%\" HEIGHT=\"32\">&nbsp;</TD><TD WIDTH=\"84%\" HEIGHT=\"32\"><INPUT TYPE=\"SUBMIT\" NAME=\"Send\" VALUE=\"Send\"><INPUT TYPE=\"RESET\" NAME=\"Reset\" VALUE=\"Reset\"></TD></TR></TABLE></FORM></BODY></HTML>";
0N/A
0N/A}
0N/A
0N/A
0N/A/**
0N/A * This class is used to store session data for each user's session. It
0N/A * is stored in the HttpSession.
0N/A */
0N/Aclass MailUserData {
0N/A URLName url;
0N/A Session session;
0N/A Store store;
0N/A Folder folder;
0N/A
0N/A public MailUserData(URLName urlname) {
0N/A url = urlname;
0N/A }
0N/A
0N/A public URLName getURLName() {
0N/A return url;
0N/A }
0N/A
0N/A public Session getSession() {
0N/A return session;
0N/A }
0N/A
0N/A public void setSession(Session s) {
0N/A session = s;
0N/A }
0N/A
0N/A public Store getStore() {
0N/A return store;
0N/A }
0N/A
0N/A public void setStore(Store s) {
0N/A store = s;
0N/A }
0N/A
0N/A public Folder getFolder() {
0N/A return folder;
0N/A }
0N/A
0N/A public void setFolder(Folder f) {
0N/A folder = f;
0N/A }
0N/A}