📄 sendbox.java
字号:
/*
* This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/).
*/
package ch05.controller;
import java.io.*;
import java.util.Hashtable;
import javax.servlet.*;
import javax.servlet.http.*;
import ch05.*;
import ch05.module.*;
/**
* 针对发件箱页面的Servlet
* @author ShenYK
* @version 1.0
*/
public class Sendbox extends HttpServlet
{
public void doGet ( HttpServletRequest request,
HttpServletResponse response )
throws ServletException, IOException
{
//设置提交表单的中文编码
request.setCharacterEncoding("GBK");
HttpSession mySession = request.getSession(true);
//清空错误消息
mySession.setAttribute("errMsg","");
//是否非法进入本页面
if ( mySession.getAttribute("username") == null )
{
response.sendRedirect("/ch05/login.jsp");
return;
}
//是否进入默认页面
if ( !request.getParameterNames().hasMoreElements() )
{
//设置session中的页面值域
mySession.setAttribute(CommonConst.VIEWID_SENDBOXLIST, new Hashtable() );
//取得最新邮件
MSendbox mSendbox = new MSendbox();
boolean bGetResult = mSendbox.getSavedMail( mySession );
mySession.setAttribute("curPage","sendbox");
response.sendRedirect("/ch05/sendbox.jsp");
return;
}
//得到用户输入信息
String sMailIndex = request.getParameter("mailIndex");
//如果用户是提交表单
if ( sMailIndex != null && sMailIndex.length() > 0 )
{
//设置session中的详细页面值域
mySession.setAttribute(CommonConst.VIEWID_SENDBOXDETAIL, new Hashtable() );
//获得对应的邮件信息
MSendbox mSendbox = new MSendbox();;
boolean bGetResult = mSendbox.compositeMail( mySession, sMailIndex );
if ( bGetResult )
{
response.sendRedirect("/ch05/composite.jsp");
}
else
{
response.sendRedirect("/ch05/sendbox.jsp");
}
return;
}
//如果用户非法进入这个页面
else
{
response.sendRedirect("/ch05/login.jsp");
}
}
public void doPost ( HttpServletRequest request,
HttpServletResponse response )
throws ServletException, IOException
{
doGet( request, response );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -