public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
try {
String name = request.getParameter("username");
String password = request.getParameter("password");
if (name.equals("") || password.equals("")) {
cas(response);
} else {
out.println("您好,您登陆的ID是:" + name);
out.println("现在是: " + new Date());
}
} catch (Exception ex) {
cas(response);
}
out.close();
}
public void cas(HttpServletResponse response)throws IOException{
PrintWriter out=response.getWriter();
out.println("<html>");
out.println("<head><title>Servlet1</title></head>");
out.println("<body bgcolor=/"#ffffff/">");
out.println("<form method=post cation=/WebModule1/servlet1>");
out.println("用户名:<input type='text' name='username'><br/>");
out.println("密码: <input type='password' name='password'><br/>");
out.println("<input type=submit value='提交'><br/>");
out.println("</form>");
out.println("</body>");
out.println("</html>");
}
在提交FORM的时候类名小写,即使类名在文件中有大写,全部转换小写,否则~~~哭吧