package org.langsin.news.control;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.langsin.news.logic.LoginLogicBean;
@SuppressWarnings("serial")
public class LoginServlet extends HttpServlet {
/**
* Constructor of the object.
*/
public LoginServlet() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @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
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String userName=request.getParameter("userName");
String userPwd=request.getParameter("userPwd");
LoginLogicBean loginBean=new LoginLogicBean();
String result=loginBean.verify(userName, userPwd);
if("OK".equals(result)){
request.getSession().setAttribute("user", userName);
request.getRequestDispatcher("main/list.jsp").forward(request, response);
}else if("PWD".equals(result)){
request.setAttribute("error", "PWD");
request.getRequestDispatcher("main/index.jsp").forward(request, response);
}else{
request.setAttribute("error", "NOUSER");
request.getRequestDispatcher("main/index.jsp").forward(request, response);
}
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occure
*/
public void init() throws ServletException {
// Put your code here
}
}
news.rar_newsfilter.org
版权申诉
76 浏览量
2022-09-21
05:03:49
上传
评论
收藏 475KB RAR 举报
![avatar](https://profile-avatar.csdnimg.cn/2416af5c19524431b870352d943af459_weixin_42659196.jpg!1)
周楷雯
- 粉丝: 82
- 资源: 1万+
最新资源
- 基于C语言的学生成绩管理系统+高分项目+源码.7z
- Delphi 12 控件之创建目录读书笔记 v1.31 (by 寂寞沙洲).zip
- 虚拟串口Virtual Serial Port Driver Pro 10 支持win10
- kubernetes resource源码
- tgyijdhrtfujt
- 基于智能推荐的卫生健康系统 JAVA+Vue.js+SpringBoot
- OUC2024年大数据原理与应用复习重点
- 使用python turtle库画一只小猪佩奇,十分有趣
- tang-boot is a front-end and back-end separation permission mana
- 手写mybatis实现,剖析mybatis底层原理
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
评论0