?? loginservlet1.java
字號:
package com.neusoft.apps;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.neusoft.sso.SsoLoginUtil;
public class LoginServlet1 extends HttpServlet {
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
/**
* 登錄模塊的任務就一個,就是在context中建立一個與該用戶對應的map
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String html = null;
String userName = request.getParameter("username");
String pw = request.getParameter("pw");
if(("shanchao".equals(userName) && "shanchao".equals(pw)) || ("hyj".equals(userName) && "hyj".equals(pw))){//登錄成功
//處理session
HttpSession session = request.getSession();
session.setAttribute("username", userName);
//處理自己的context
SsoLoginUtil.createSso(request, userName);/////////
html = "index.html";
}else{//登錄失敗
html = "login.html";
}
RequestDispatcher rd = request.getRequestDispatcher(html);
rd.forward(request, response);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -