?? setting.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 Setting extends HttpServlet
{
public void doGet ( HttpServletRequest request,
HttpServletResponse response )
throws ServletException, IOException
{
//設置提交表單的中文編碼
request.setCharacterEncoding("GBK");
HttpSession mySession = request.getSession(true);
//清空錯誤消息
mySession.setAttribute("errMsg","");
//設置session中的頁面值域
mySession.setAttribute(CommonConst.VIEWID_SETTING, new Hashtable() );
//是否非法進入本頁面
if ( mySession.getAttribute("username") == null )
{
response.sendRedirect("/ch05/login.jsp");
return;
}
//是否進入默認頁面
if ( !request.getParameterNames().hasMoreElements() )
{
//校驗用戶輸入信息
MSetting mSetting = new MSetting();
mSetting.getSettingInfo( mySession );
mySession.setAttribute("curPage","setting");
response.sendRedirect("/ch05/setting.jsp");
return;
}
//得到用戶輸入信息
String sPop3Ip = request.getParameter("pop3Ip");
String sPop3User = request.getParameter("pop3User");
String sPop3Pass = request.getParameter("pop3Pass");
String sSmtpIp = request.getParameter("smtpIp");
String sSmtpUser = request.getParameter("smtpUser");
String sSmtpPass = request.getParameter("smtpPass");
String sAddress = request.getParameter("address");
//如果用戶是提交表單
if ( sPop3Ip != null && sPop3Ip.length() > 0 )
{
//校驗用戶輸入信息
MSetting mSetting = new MSetting();
boolean bCheckResult = mSetting.registerSetting( mySession,
sPop3Ip,
sPop3User,
sPop3Pass,
sSmtpIp,
sSmtpUser,
sSmtpPass,
sAddress );
if ( bCheckResult )
{
response.sendRedirect("/ch05/settingSuccessful.jsp");
}
else
{
response.sendRedirect("/ch05/setting.jsp");
}
}
//如果用戶非法進入這個頁面
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 + -