编写JSP实现⽤户登录并判断⽤户或密码1、登录页代码
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="zhuye.jsp" method="post">
<input type="text" name="name">
<br>
<input type="password" name="password">
<br>
<input type="submit" value="提交">
</form>
</body>
</html>
2、判断页代码
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>html实现用户注册登录代码
<body>
<%
String Parameter("name");
String Parameter("password");
%>
<%
if(name.equals("name")&&password.equals("asd123456"))
{
out.print("输⼊正确");
}else{%>
<jsp:forward page="cuowuye.jsp"></jsp:forward>
<% }%>
</body>
</html>
3、跳转到的错误页代码并3秒后跳回登录页
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
输⼊错误
<%
response.setHeader("refresh", "3;URL=shuruye.jsp");
%>
</body>
</html>
4、运⾏结果
(1)输⼊正确时运⾏结果
(2)输⼊错误时,运⾏结果

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。