1 39 40 package demo; 41 42 import java.util.*; 43 import javax.mail.*; 44 import javax.mail.internet.*; 45 import javax.servlet.jsp.*; 46 import javax.servlet.jsp.tagext.*; 47 48 51 public class MessageTag extends TagSupport { 52 private String folder; 53 private String session; 54 private int num = 1; 55 56 59 public String getFolder() { 60 return folder; 61 } 62 63 66 public String getNum() { 67 return Integer.toString(num); 68 } 69 70 73 public String getSession() { 74 return session; 75 } 76 77 80 public void setFolder(String folder) { 81 this.folder = folder; 82 } 83 84 87 public void setNum(String num) { 88 this.num = Integer.parseInt(num); 89 } 90 91 94 public void setSession(String session) { 95 this.session = session; 96 } 97 98 101 public int doStartTag() throws JspException { 102 MessageInfo messageinfo = new MessageInfo(); 103 try { 104 Folder f = (Folder)pageContext.getAttribute( 105 getFolder(), PageContext.SESSION_SCOPE); 106 Message message = f.getMessage(num); 107 messageinfo.setMessage(message); 108 pageContext.setAttribute(getId(), messageinfo); 109 } catch (Exception ex) { 110 throw new JspException(ex.getMessage()); 111 } 112 113 return SKIP_BODY; 114 } 115 } 116 117 | Popular Tags |