<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<%@ page import="javautil" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 401 Transitional//EN">
<html>
<head>
<title>登录页面</title>
</head>
<body>
<form name="loginForm" method="post" action="judgeUserjsp">
<table>
<tr>
<td>用户名:<input type="text" name="userName" id="userName"></td>
</tr>
<tr>
<td>密码:<input type="password" name="password" id="password"></td>
</tr>
<tr>
<td><input type="submit" value="登录" style="background-color:pink"> <input type="reset" value="重置" style="background-color:red"></td>
</tr>
</table>
</form>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<%@ page import="javautil" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 401 Transitional//EN">
<html>
<head>
<title>身份验证</title>
</head>
<body>
<%
requestsetCharacterEncoding("GB18030");
String name = requestgetParameter("userName");
String password = requestgetParameter("password");
if(nameequals("abc")&& passwordequals("123")) {
%>
<jsp:forward page="afterLoginjsp">
<jsp:param name="userName" value="<%=name%>"/>
</jsp:forward>
<%
}
else {
%>
<jsp:forward page="loginjsp"/>
<%
}
%>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 401 Transitional//EN">
<html>
<head>
<title>登录成功</title>
</head>
<body>
<%
requestsetCharacterEncoding("GB18030");
String name = requestgetParameter("userName");
outprintln("欢迎你:" + name);
%>
</body>
</html>//这句是用response跳转到你要跳转的页面,并将值usename传递过去,
responsesendRedirect("你要跳转的页面jspusename="+usename);
//在你要跳转的页面,就用request获取就行了。
<h1><%=requestgetParameter("usename")%>!欢迎你的登陆!</h1>
具体的话,应该是这么写,其实也还有其他的方法,我就只记得这一个了,希望能帮到你
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)