首先要有优美的登陆界面,这个是在jsp界面中写的
如下代码所示:
login.jsp界面
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
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>用户登陆</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">
-->
<script type="text/javascript">
function change(){
var imgcode = document.getElementById("imgcode");
imgcode.src = "<%=path%>/CreateImgCodeServlet?a="+new Date().getTime();
}
</script>
</head>
<body>
<h1>用户登录</h1>
<font color="red">${requestScope.message } </font>
<form action="${pageContext.request.contextPath}/LoginServlet " method="post">
<p>
账号:<input type="text" name="username" value="${cookie.username.value }" />
</p>
<p>
密码:<input type="password" name="password" value="${cookie.password.value }" />
</p>
<p>
验证码:<input type="text" name="imgcode" size="10" />
<img id="imgcode" alt="验证码" src="${pageContext.request.contextPath }/CreateImgCodeServlet">
<a href="javascript:change()">换一张</a>
</p>
<p>
<input ty