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");
}
}
}
标签: