RSS订阅悠然探索,悠然索取
你的位置:首页 » JAVA » 正文

CUserLoginServlet

选择字号: 超大 标准 发布时间:2013-3-29 14:17:27 | 作者:admin | 0个评论 | 人浏览

 package net.lisoft.service.servlet;

 
import java.io.IOException;
 
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
public class CUserLoginServlet extends HttpServlet implements
javax.servlet.Servlet {
 
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
// TODO Auto-generated method stub
this.log("执行doGet方法...");
execute(req, resp);
// super.doGet(req, resp);
 
}
 
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
// TODO Auto-generated method stub
this.log("执行doPost方法...");
execute(req, resp);
// super.doPost(req, resp);
}
 
private void execute(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("gbk");
request.setCharacterEncoding("gbk");
String requestURI = request.getRequestURI();
String method = request.getMethod();
String username = request.getParameter("txtLoginName");
String userpwd = request.getParameter("txtLoginPwd");
this.log("username=" + username + ",userpwd=" + userpwd);
request.getSession().setAttribute("username", username);
if (!username.equals("admin") || userpwd.equals("123")) {
CBasicService.LcMessage(response, "用户名或者密码错误");
} else {
response.sendRedirect("../admin/desktop/main.jsp");
}
}
}
 

标签:

猜你喜欢

发表评论

必填

选填

选填

必填,不填不让过哦,嘻嘻。

记住我,下次回复时不用重新输入个人信息

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。