这是我的表单的HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<p>请输入用户名和密码:</p>
<form id="form1" name="form1" method="post" action="/webproject2/servlet/login">
<table width="236" border="0" height="104">
<tr>
<td width="69">用户名:</td>
<td width="147"><label>
<input name="username" type="text" id="username" size="18" maxlength="20" />
</label></td>
</tr>
<tr>
<td> 密 码:</td>
<td><label>
<input name="password" type="password" id="password" size="18" maxlength="20" />
</label></td>
</tr>
<tr>
<td><label>
<input type="submit" name="Submit" value="提交" />
</label></td>
<td><label>
<input name="reset" type="reset" id="reset" value="重置" />
</label></td>
</tr>
</table>
</form>
<p> </p>
</body>
</html>
这是我的WEB.XML配置
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd">
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>LoginServlet</servlet-name>
<servlet-class>exercise2.LoginServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>LoginServlet</servlet-name>
<url-pattern>/servlet/login</url-pattern>
</servlet-mapping>
</web-app>
这是我的servlet程序
package exercise2;
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;
public class LoginServlet extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = -7151922507452534516L;
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=utf-8");
PrintWriter out = response.getWriter();
out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
out.println("<HTML>");
out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");
out.println(" <BODY>");