📄 loginservlet2.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 LoginServlet2 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)){//登录成功
//处理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 + -