?? 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 + -