1,登录页面
<%@ page language="java" import="java.util.*" pageEncoding="gbk" errorPage="error.jsp"%>
<%
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 'index.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">
-->
<script language="javascript">
function check(form)
{
if(form.txtusername.value=="" || form.txtusername.value==null){
alert("请输入用户名!");
return false;
}else if(form.txtpassword.value=="" || form.txtpassword.value==null){
alert("请输入密码!");
return false;
}else{
return true;
}
}
</script>
</head>
<body>
<!-- 用于输入错误 -->
<font color="red">
<%
if(request.getAttribute("err")!=null){
out.print(request.getAttribute("err"));
}
%>
</font>
<form id="login" method="post" action="loginservlet" οnsubmit="check(this)">
<table border="1" align="center">
<tr>
<td>用户名</td>
<td><label>
<input type="text" name="txtusername" />
</label></td>
</tr>
<tr>
<td>密码</td>
<td><input type="password" name="txtpassword" /></td>
</tr>
<tr>
<td> </td>
<td>
<input type="submit" name="txtSubmit" value="提交" />
</td>
</tr>
</table>
</form>
</body>
</html>
2,欢迎页面
<%@ page language="java" import="java.util.*" pageEncoding="gbk" errorPage="error.jsp"%>
<%
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 'MyJsp.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>
欢迎你,<%=session.getAttribute("username")%>
</body>
</html>
3,出错页面
<%@ page language="java" import="java.util.*" pageEncoding="gbk" isErrorPage="true"%>
<%
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 'error.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>
<font color="red">
<%
if(exception!=null){
out.print(exception.getMessage()+"<br>");
}
%>
</font>
</body>
</html>