login.jsp

来自「JDBC数据库高级编程源代码」· JSP 代码 · 共 54 行

JSP
54
字号
<%@ page contentType="text/html;charset=gb2312"%>
<%-- 进行登录验证 --%>
<%
	String user = request.getParameter( "user" );
	String password = request.getParameter( "password" );
	if( "scott".equals( user ) && "tiger".equals( "tiger" ) )
	{
%>
		<jsp:forward page="success.jsp">
			<jsp:param name="user" value="<%=user%>" />
		</jsp:forward>
<%
	}
%>
<html>
<head>
<title>登录页面</title>
</head>
<body>
<center>
<table border="0" width="300">
	<tr>
		<td colspan="2" align="center">用户登录</td>
	</tr>
	<%-- 输出错误信息 --%>
	<%
		if( null!=user )
		{
	%>
	<tr>
		<td colspan="2">用户名密码验证失败!请重新输入!</td>
	</tr>
	<%
		}
	%>
	<form method="post" action="login.jsp" />
	<tr>
		<td align="right">登录名:</td>
		<td><input type="text" name="user"></td>
	</tr>
	<tr>
		<td align="right">密码:</td>
		<td><input type="password" name="password"></td>
	</tr>
	<tr>
		<td colspan="2" align="center"><input type="submit" value="登 录"></td>
	</tr>
	</form>
</table>
</center>
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?