主要代码
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String username=request.getParameter("uname");
String userpass=request.getParameter("upass");
if(username.equals("jack")&&userpass.equals("abcd"))
{
RequestDispatcher dis=request.getRequestDispatcher("Wlecome.jsp");
dis.forward(request, response);//完成跳转
}
else{
response.sendRedirect("Login.jsp");
}
}
注意:使用的时候要注意web.xml的路径 不小心很容易做成路径找不到,所以注意路径必须是新手完成作业的关键!!!!