package com.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class LoginServlet
*/
@WebServlet("/Judge")
public class LoginServlet extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)throws ServletException,IOException{
response.setContentType("text/html;charset=gbk");
PrintWriter out =response.getWriter();
String userid =request.getParameter("userid");
String password =request.getParameter("password");
if((userid.equals("admin"))&&(password.equals("test"))){
RequestDispatcher dispatcher =getServletConfig().getServletContext().getRequestDispatcher("/loginSuccess");
dispatcher.forward(request,response);
}else{
RequestDispatcher dispatcher =getServletConfig().getServletContext().getRequestDispatcher("/loginFail");
dispatcher.forward(request,response);
}
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
processRequest(request,response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
processRequest(request,response);
}
}
rookie2maven
相关分类