viewmessagelistaction.java
来自「21天学通java的示例程序源代码」· Java 代码 · 共 49 行
JAVA
49 行
package ezmail;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.mail.Session;
import javax.mail.Folder;
import javax.mail.Message;
public class ViewMessageListAction implements Action {
public ViewMessageListAction() {
}
/**
* Performs the following steps...
* <ol>
* <li>....</li>
* </ol>
*
* The data is then placed in the user's session. The attribute is named
* <code>Constants.DATA</code>
*/
public void perform(ServletContext servletContext,
HttpServletRequest request,
HttpServletResponse response) throws ActionException {
try {
HttpSession theHttpSession = request.getSession();
// retrieve the mail session
Session mailSession = (Session) theHttpSession.getAttribute(Constants.MAIL_SESSION);
UserInfo theUserInfo = (UserInfo) theHttpSession.getAttribute(Constants.USER_INFO);
// retrieve the messages from the user's inbox
Message[] msgs = MailHelper.getMessages(mailSession, theUserInfo);
// place the messages in the http session
theHttpSession.setAttribute(Constants.MESSAGE_LIST, msgs);
}
catch (Exception exc) {
exc.printStackTrace();
throw new ActionException(exc.getMessage());
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?