servlet的代码为:
package servlet.wl.com;import java.io.IOException;
import java.io.PrintWriter;import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;import User.wl.com.CheckUser;public class CheckLoginServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
  response.setContentType("text/html");
  response.setCharacterEncoding("UTF-8");
 String username=request.getParameter("username");
    String password=request.getParameter("password");
    HttpSession session=request.getSession();
    session.setAttribute("user", username);
    CheckUser user=new CheckUser();
    boolean i=user.check(username, password);
    out.print(i);
if (i==true){
    request.getRequestDispatcher("loginsuccess.jsp").forward(request, response);
   }else{
     response.sendRedirect("loginError.jsp");
    }  


}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { this.doGet(request, response);
}}登录成功显示loginsuccess.jsp,代码为
<%@ page language="java" contentType="text/html; charset=UTF-8" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'loginsuccess.jsp' starting page</title>
    
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->  </head>
  
  <body>
 登录成功! <br>
  </body>
</html>