Advertisement
Guest User

Untitled

a guest
Jan 30th, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.25 KB | None | 0 0
  1. /*
  2. * Copyright (c) 1998-2011 Oracle and/or its affiliates. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. *
  8. * - Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. *
  11. * - Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. *
  15. * - Neither the name of Oracle nor the names of its
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
  20. * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  21. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  22. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  23. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  24. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  25. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  26. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  27. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  28. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  29. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. */
  31.  
  32. import java.io.*;
  33. import java.util.*;
  34. import java.text.*;
  35.  
  36. import javax.servlet.*;
  37. import javax.servlet.http.*;
  38. import javax.mail.*;
  39. import javax.mail.Part;
  40. import javax.mail.internet.*;
  41. import javax.activation.*;
  42.  
  43.  
  44. /**
  45. * This is a servlet that demonstrates the use of JavaMail APIs
  46. * in a 3-tier application. It allows the user to login to an
  47. * IMAP store, list all the messages in the INBOX folder, view
  48. * selected messages, compose and send a message, and logout.
  49. * <p>
  50. * Please note: This is NOT an example of how to write servlets!
  51. * This is simply to show that JavaMail can be used in a servlet.
  52. * <p>
  53. * For more information on this servlet, see the
  54. * JavaMailServlet.README.txt file.
  55. * <p>
  56. * For more information on servlets, see
  57. * <a href="http://java.sun.com/products/java-server/servlets/index.html">
  58. * http://java.sun.com/products/java-server/servlets/index.html</a>
  59. *
  60. * @author Max Spivak
  61. */
  62. public class JavaMailServlet extends HttpServlet implements SingleThreadModel {
  63. String protocol = "imap";
  64. String mbox = "INBOX";
  65.  
  66.  
  67. /**
  68. * This method handles the "POST" submission from two forms: the
  69. * login form and the message compose form. The login form has the
  70. * following parameters: <code>hostname</code>, <code>username</code>,
  71. * and <code>password</code>. The <code>send</code> parameter denotes
  72. * that the method is processing the compose form submission.
  73. */
  74. public void doPost(HttpServletRequest req, HttpServletResponse res)
  75. throws ServletException, IOException {
  76.  
  77. // get the session
  78. HttpSession ssn = req.getSession(true);
  79.  
  80. String send = req.getParameter("send");
  81. String host = req.getParameter("hostname");
  82. String user = req.getParameter("username");
  83. String passwd = req.getParameter("password");
  84. URLName url = new URLName(protocol, host, -1, mbox, user, passwd);
  85.  
  86. ServletOutputStream out = res.getOutputStream();
  87. res.setContentType("text/html");
  88. out.println("<html><body bgcolor=\"#CCCCFF\">");
  89.  
  90. if (send != null) {
  91. // process message sending
  92. send(req, res, out, ssn);
  93.  
  94. } else {
  95. // initial login
  96.  
  97. // create
  98. MailUserData mud = new MailUserData(url);
  99. ssn.putValue("javamailservlet", mud);
  100.  
  101. try {
  102. Properties props = System.getProperties();
  103. props.put("mail.smtp.host", host);
  104. Session session = Session.getDefaultInstance(props, null);
  105. session.setDebug(false);
  106. Store store = session.getStore(url);
  107. store.connect();
  108. Folder folder = store.getDefaultFolder();
  109. if (folder == null)
  110. throw new MessagingException("No default folder");
  111.  
  112. folder = folder.getFolder(mbox);
  113. if (folder == null)
  114. throw new MessagingException("Invalid folder");
  115.  
  116. folder.open(Folder.READ_WRITE);
  117. int totalMessages = folder.getMessageCount();
  118. Message[] msgs = folder.getMessages();
  119. FetchProfile fp = new FetchProfile();
  120. fp.add(FetchProfile.Item.ENVELOPE);
  121. folder.fetch(msgs, fp);
  122.  
  123. // track who logged in
  124. System.out.println("Login from: " + store.getURLName());
  125.  
  126. // save stuff into MUD
  127. mud.setSession(session);
  128. mud.setStore(store);
  129. mud.setFolder(folder);
  130.  
  131. // splash
  132. out.print("<center>");
  133. out.print("<font face=\"Arial,Helvetica\" font size=+3>");
  134. out.println("<b>Welcome to JavaMail!</b></font></center><p>");
  135.  
  136. // folder table
  137. out.println("<table width=\"50%\" border=0 align=center>");
  138. // folder name column header
  139. out.print("<tr><td width=\"75%\" bgcolor=\"#ffffcc\">");
  140. out.print("<font face=\"Arial,Helvetica\" font size=-1>");
  141. out.println("<b>FolderName</b></font></td><br>");
  142. // msg count column header
  143. out.print("<td width=\"25%\" bgcolor=\"#ffffcc\">");
  144. out.print("<font face=\"Arial,Helvetica\" font size=-1>");
  145. out.println("<b>Messages</b></font></td><br>");
  146. out.println("</tr>");
  147. // folder name
  148. out.print("<tr><td width=\"75%\" bgcolor=\"#ffffff\">");
  149. out.print("<a href=\"" + HttpUtils.getRequestURL(req) + "\">" +
  150. "Inbox" + "</a></td><br>");
  151. // msg count
  152. out.println("<td width=\"25%\" bgcolor=\"#ffffff\">" +
  153. totalMessages + "</td>");
  154. out.println("</tr>");
  155. out.println("</table");
  156. } catch (Exception ex) {
  157. out.println(ex.toString());
  158. } finally {
  159. out.println("</body></html>");
  160. out.close();
  161. }
  162. }
  163. }
  164.  
  165.  
  166. /**
  167. * This method handles the GET requests for the client.
  168. */
  169. public void doGet (HttpServletRequest req, HttpServletResponse res)
  170. throws ServletException, IOException {
  171.  
  172. HttpSession ses = req.getSession(false); // before we write to out
  173. ServletOutputStream out = res.getOutputStream();
  174. MailUserData mud = getMUD(ses);
  175.  
  176. if (mud == null) {
  177. res.setContentType("text/html");
  178. out.println("<html><body>Please Login (no session)</body></html>");
  179. out.close();
  180. return;
  181. }
  182.  
  183. if (!mud.getStore().isConnected()) {
  184. res.setContentType("text/html");
  185. out.println("<html><body>Not Connected To Store</body></html>");
  186. out.close();
  187. return;
  188. }
  189.  
  190.  
  191. // mux that takes a GET request, based on parameters figures
  192. // out what it should do, and routes it to the
  193. // appropriate method
  194.  
  195. // get url parameters
  196. String msgStr = req.getParameter("message");
  197. String logout = req.getParameter("logout");
  198. String compose = req.getParameter("compose");
  199. String part = req.getParameter("part");
  200. int msgNum = -1;
  201. int partNum = -1;
  202.  
  203. // process url params
  204. if (msgStr != null) {
  205. // operate on message "msgStr"
  206. msgNum = Integer.parseInt(msgStr);
  207.  
  208. if (part == null) {
  209. // display message "msgStr"
  210. res.setContentType("text/html");
  211. displayMessage(mud, req, out, msgNum);
  212.  
  213. } else {
  214. // display part "part" in message "msgStr"
  215. partNum = Integer.parseInt(part);
  216. displayPart(mud, msgNum, partNum, out, res);
  217. }
  218.  
  219. } else if (compose != null) {
  220. // display compose form
  221. compose(mud, res, out);
  222.  
  223. } else if (logout != null) {
  224. // process logout
  225. try {
  226. mud.getFolder().close(false);
  227. mud.getStore().close();
  228. ses.invalidate();
  229. out.println("<html><body>Logged out OK</body></html>");
  230. } catch (MessagingException mex) {
  231. out.println(mex.toString());
  232. }
  233.  
  234. } else {
  235. // display headers
  236. displayHeaders(mud, req, out);
  237. }
  238. }
  239.  
  240. /* main method to display messages */
  241. private void displayMessage(MailUserData mud, HttpServletRequest req,
  242. ServletOutputStream out, int msgNum)
  243. throws IOException {
  244.  
  245. out.println("<html>");
  246. out.println("<HEAD><TITLE>JavaMail Servlet</TITLE></HEAD>");
  247. out.println("<BODY bgcolor=\"#ccccff\">");
  248. out.print("<center><font face=\"Arial,Helvetica\" ");
  249. out.println("font size=\"+3\"><b>");
  250. out.println("Message " + (msgNum+1) + " in folder " +
  251. mud.getStore().getURLName() +
  252. "/INBOX</b></font></center><p>");
  253.  
  254. try {
  255. Message msg = mud.getFolder().getMessage(msgNum);
  256.  
  257. // first, display this message's headers
  258. displayMessageHeaders(mud, msg, out);
  259.  
  260. // and now, handle the content
  261. Object o = msg.getContent();
  262.  
  263. //if (o instanceof String) {
  264. if (msg.isMimeType("text/plain")) {
  265. out.println("<pre>");
  266. out.println((String)o);
  267. out.println("</pre>");
  268. //} else if (o instanceof Multipart){
  269. } else if (msg.isMimeType("multipart/*")) {
  270. Multipart mp = (Multipart)o;
  271. int cnt = mp.getCount();
  272. for (int i = 0; i < cnt; i++) {
  273. displayPart(mud, msgNum, mp.getBodyPart(i), i, req, out);
  274. }
  275. } else {
  276. out.println(msg.getContentType());
  277. }
  278.  
  279. } catch (MessagingException mex) {
  280. out.println(mex.toString());
  281. }
  282.  
  283. out.println("</BODY></html>");
  284. out.close();
  285. }
  286.  
  287. /**
  288. * This method displays a message part. <code>text/plain</code>
  289. * content parts are displayed inline. For all other parts,
  290. * a URL is generated and displayed; clicking on the URL
  291. * brings up the part in a separate page.
  292. */
  293. private void displayPart(MailUserData mud, int msgNum, Part part,
  294. int partNum, HttpServletRequest req,
  295. ServletOutputStream out)
  296. throws IOException {
  297.  
  298. if (partNum != 0)
  299. out.println("<p><hr>");
  300.  
  301. try {
  302.  
  303. String sct = part.getContentType();
  304. if (sct == null) {
  305. out.println("invalid part");
  306. return;
  307. }
  308. ContentType ct = new ContentType(sct);
  309.  
  310. if (partNum != 0)
  311. out.println("<b>Attachment Type:</b> " +
  312. ct.getBaseType() + "<br>");
  313.  
  314. if (ct.match("text/plain")) {
  315. // display text/plain inline
  316. out.println("<pre>");
  317. out.println((String)part.getContent());
  318. out.println("</pre>");
  319.  
  320. } else {
  321. // generate a url for this part
  322. String s;
  323. if ((s = part.getFileName()) != null)
  324. out.println("<b>Filename:</b> " + s + "<br>");
  325. s = null;
  326. if ((s = part.getDescription()) != null)
  327. out.println("<b>Description:</b> " + s + "<br>");
  328.  
  329. out.println("<a href=\"" +
  330. HttpUtils.getRequestURL(req) +
  331. "?message=" +
  332. msgNum + "&part=" +
  333. partNum + "\">Display Attachment</a>");
  334. }
  335. } catch (MessagingException mex) {
  336. out.println(mex.toString());
  337. }
  338. }
  339.  
  340. /**
  341. * This method gets the stream from for a given msg part and
  342. * pushes it out to the browser with the correct content type.
  343. * Used to display attachments and relies on the browser's
  344. * content handling capabilities.
  345. */
  346. private void displayPart(MailUserData mud, int msgNum,
  347. int partNum, ServletOutputStream out,
  348. HttpServletResponse res)
  349. throws IOException {
  350.  
  351. Part part = null;
  352.  
  353. try {
  354. Message msg = mud.getFolder().getMessage(msgNum);
  355.  
  356. Multipart mp = (Multipart)msg.getContent();
  357. part = mp.getBodyPart(partNum);
  358.  
  359. String sct = part.getContentType();
  360. if (sct == null) {
  361. out.println("invalid part");
  362. return;
  363. }
  364. ContentType ct = new ContentType(sct);
  365.  
  366. res.setContentType(ct.getBaseType());
  367. InputStream is = part.getInputStream();
  368. int i;
  369. while ((i = is.read()) != -1)
  370. out.write(i);
  371. out.flush();
  372. out.close();
  373. } catch (MessagingException mex) {
  374. out.println(mex.toString());
  375. }
  376. }
  377.  
  378. /**
  379. * This is a utility message that pretty-prints the message
  380. * headers for message that is being displayed.
  381. */
  382. private void displayMessageHeaders(MailUserData mud, Message msg,
  383. ServletOutputStream out)
  384. throws IOException {
  385.  
  386. try {
  387. out.println("<b>Date:</b> " + msg.getSentDate() + "<br>");
  388.  
  389. Address[] fr = msg.getFrom();
  390. if (fr != null) {
  391. boolean tf = true;
  392. out.print("<b>From:</b> ");
  393. for (int i = 0; i < fr.length; i++) {
  394. out.print(((tf) ? " " : ", ") + getDisplayAddress(fr[i]));
  395. tf = false;
  396. }
  397. out.println("<br>");
  398. }
  399.  
  400. Address[] to = msg.getRecipients(Message.RecipientType.TO);
  401. if (to != null) {
  402. boolean tf = true;
  403. out.print("<b>To:</b> ");
  404. for (int i = 0; i < to.length; i++) {
  405. out.print(((tf) ? " " : ", ") + getDisplayAddress(to[i]));
  406. tf = false;
  407. }
  408. out.println("<br>");
  409. }
  410.  
  411. Address[] cc = msg.getRecipients(Message.RecipientType.CC);
  412. if (cc != null) {
  413. boolean cf = true;
  414. out.print("<b>CC:</b> ");
  415. for (int i = 0; i < cc.length; i++) {
  416. out.print(((cf) ? " " : ", ") + getDisplayAddress(cc[i]));
  417. cf = false;
  418. }
  419. out.println("<br>");
  420. }
  421.  
  422. out.print("<b>Subject:</b> " +
  423. ((msg.getSubject() !=null) ? msg.getSubject() : "") +
  424. "<br>");
  425.  
  426. } catch (MessagingException mex) {
  427. out.println(msg.toString());
  428. }
  429. }
  430.  
  431. /**
  432. * This method displays the URL's for the available commands and the
  433. * INBOX headerlist
  434. */
  435. private void displayHeaders(MailUserData mud,
  436. HttpServletRequest req,
  437. ServletOutputStream out)
  438. throws IOException {
  439.  
  440. SimpleDateFormat df = new SimpleDateFormat("EE M/d/yy");
  441.  
  442. out.println("<html>");
  443. out.println("<HEAD><TITLE>JavaMail Servlet</TITLE></HEAD>");
  444. out.println("<BODY bgcolor=\"#ccccff\"><hr>");
  445. out.print("<center><font face=\"Arial,Helvetica\" font size=\"+3\">");
  446. out.println("<b>Folder " + mud.getStore().getURLName() +
  447. "/INBOX</b></font></center><p>");
  448.  
  449. // URL's for the commands that are available
  450. out.println("<font face=\"Arial,Helvetica\" font size=\"+3\"><b>");
  451. out.println("<a href=\"" +
  452. HttpUtils.getRequestURL(req) +
  453. "?logout=true\">Logout</a>");
  454. out.println("<a href=\"" +
  455. HttpUtils.getRequestURL(req) +
  456. "?compose=true\" target=\"compose\">Compose</a>");
  457. out.println("</b></font>");
  458. out.println("<hr>");
  459.  
  460. // List headers in a table
  461. out.print("<table cellpadding=1 cellspacing=1 "); // table
  462. out.println("width=\"100%\" border=1>"); // settings
  463.  
  464. // sender column header
  465. out.println("<tr><td width=\"25%\" bgcolor=\"ffffcc\">");
  466. out.println("<font face=\"Arial,Helvetica\" font size=\"+1\">");
  467. out.println("<b>Sender</b></font></td>");
  468. // date column header
  469. out.println("<td width=\"15%\" bgcolor=\"ffffcc\">");
  470. out.println("<font face=\"Arial,Helvetica\" font size=\"+1\">");
  471. out.println("<b>Date</b></font></td>");
  472. // subject column header
  473. out.println("<td bgcolor=\"ffffcc\">");
  474. out.println("<font face=\"Arial,Helvetica\" font size=\"+1\">");
  475. out.println("<b>Subject</b></font></td></tr>");
  476.  
  477. try {
  478. Folder f = mud.getFolder();
  479. int msgCount = f.getMessageCount();
  480. Message m = null;
  481. // for each message, show its headers
  482. for (int i = 1; i <= msgCount; i++) {
  483. m = f.getMessage(i);
  484.  
  485. // if message has the DELETED flag set, don't display it
  486. if (m.isSet(Flags.Flag.DELETED))
  487. continue;
  488.  
  489. // from
  490. out.println("<tr valigh=middle>");
  491. out.print("<td width=\"25%\" bgcolor=\"ffffff\">");
  492. out.println("<font face=\"Arial,Helvetica\">" +
  493. ((m.getFrom() != null) ?
  494. m.getFrom()[0].toString() :
  495. "" ) +
  496. "</font></td>");
  497.  
  498. // date
  499. out.print("<td nowrap width=\"15%\" bgcolor=\"ffffff\">");
  500. out.println("<font face=\"Arial,Helvetica\">" +
  501. df.format((m.getSentDate()!=null) ?
  502. m.getSentDate() : m.getReceivedDate()) +
  503. "</font></td>");
  504.  
  505. // subject & link
  506. out.print("<td bgcolor=\"ffffff\">");
  507. out.println("<font face=\"Arial,Helvetica\">" +
  508. "<a href=\"" +
  509. HttpUtils.getRequestURL(req) +
  510. "?message=" +
  511. i + "\">" +
  512. ((m.getSubject() != null) ?
  513. m.getSubject() :
  514. "<i>No Subject</i>") +
  515. "</a>" +
  516. "</font></td>");
  517. out.println("</tr>");
  518. }
  519. } catch (MessagingException mex) {
  520. out.println("<tr><td>" + mex.toString() + "</td></tr>");
  521. mex.printStackTrace();
  522. }
  523.  
  524. out.println("</table>");
  525. out.println("</BODY></html>");
  526. out.flush();
  527. out.close();
  528. }
  529.  
  530. /**
  531. * This method handles the request when the user hits the
  532. * <i>Compose</i> link. It send the compose form to the browser.
  533. */
  534. private void compose(MailUserData mud, HttpServletResponse res,
  535. ServletOutputStream out)
  536. throws IOException {
  537.  
  538. res.setContentType("text/html");
  539. out.println(composeForm);
  540. out.close();
  541. }
  542.  
  543. /**
  544. * This method processes the send request from the compose form
  545. */
  546. private void send(HttpServletRequest req, HttpServletResponse res,
  547. ServletOutputStream out, HttpSession ssn)
  548. throws IOException {
  549.  
  550. String to = req.getParameter("to");
  551. String cc = req.getParameter("cc");
  552. String subj = req.getParameter("subject");
  553. String text = req.getParameter("text");
  554.  
  555. try {
  556. MailUserData mud = getMUD(ssn);
  557. if (mud == null)
  558. throw new Exception("trying to send, but not logged in");
  559.  
  560. Message msg = new MimeMessage(mud.getSession());
  561. InternetAddress[] toAddrs = null, ccAddrs = null;
  562.  
  563. if (to != null) {
  564. toAddrs = InternetAddress.parse(to, false);
  565. msg.setRecipients(Message.RecipientType.TO, toAddrs);
  566. } else
  567. throw new MessagingException("No \"To\" address specified");
  568.  
  569. if (cc != null) {
  570. ccAddrs = InternetAddress.parse(cc, false);
  571. msg.setRecipients(Message.RecipientType.CC, ccAddrs);
  572. }
  573.  
  574. if (subj != null)
  575. msg.setSubject(subj);
  576.  
  577. URLName u = mud.getURLName();
  578. msg.setFrom(new InternetAddress(u.getUsername() + "@" +
  579. u.getHost()));
  580.  
  581. if (text != null)
  582. msg.setText(text);
  583.  
  584. Transport.send(msg);
  585.  
  586. out.println("<h1>Message sent successfully</h1></body></html>");
  587. out.close();
  588.  
  589. } catch (Exception mex) {
  590. out.println("<h1>Error sending message.</h1>");
  591. out.println(mex.toString());
  592. out.println("<br></body></html>");
  593. }
  594. }
  595.  
  596.  
  597. // utility method; returns a string suitable for msg header display
  598. private String getDisplayAddress(Address a) {
  599. String pers = null;
  600. String addr = null;
  601. if (a instanceof InternetAddress &&
  602. ((pers = ((InternetAddress)a).getPersonal()) != null)) {
  603.  
  604. addr = pers + " "+"&lt;"+((InternetAddress)a).getAddress()+"&gt;";
  605. } else
  606. addr = a.toString();
  607.  
  608. return addr;
  609. }
  610.  
  611. // utility method; retrieve the MailUserData
  612. // from the HttpSession and return it
  613. private MailUserData getMUD(HttpSession ses) throws IOException {
  614. MailUserData mud = null;
  615.  
  616. if (ses == null) {
  617. return null;
  618. } else {
  619. if ((mud = (MailUserData)ses.getValue("javamailservlet")) == null){
  620. return null;
  621. }
  622. }
  623. return mud;
  624. }
  625.  
  626.  
  627. public String getServletInfo() {
  628. return "A mail reader servlet";
  629. }
  630.  
  631. /**
  632. * This is the HTML code for the compose form. Another option would
  633. * have been to use a separate html page.
  634. */
  635. 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>";
  636.  
  637. }
  638.  
  639.  
  640. /**
  641. * This class is used to store session data for each user's session. It
  642. * is stored in the HttpSession.
  643. */
  644. class MailUserData {
  645. URLName url;
  646. Session session;
  647. Store store;
  648. Folder folder;
  649.  
  650. public MailUserData(URLName urlname) {
  651. url = urlname;
  652. }
  653.  
  654. public URLName getURLName() {
  655. return url;
  656. }
  657.  
  658. public Session getSession() {
  659. return session;
  660. }
  661.  
  662. public void setSession(Session s) {
  663. session = s;
  664. }
  665.  
  666. public Store getStore() {
  667. return store;
  668. }
  669.  
  670. public void setStore(Store s) {
  671. store = s;
  672. }
  673.  
  674. public Folder getFolder() {
  675. return folder;
  676. }
  677.  
  678. public void setFolder(Folder f) {
  679. folder = f;
  680. }
  681. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement