《JSP完全学习手册》学习心得:jsp:forward
Judgment.jsp:
<%@ page contentType="text/html; charset=gb2312" language="java"%>
<html>
<head>
</head>
<body>
<%
String User=request.getParameter("User");
String Password=request.getParameter("Password");
if(User.equals("Admin") && Password.equals("Admin")) { %>
<jsp:forward page="welcome.jsp"/>
<% }
else
{ %>
<jsp:forward page="Login.html"/>
<% } %>
</body>
</html>
welcome.jsp
<%@ page contentType="text/html; charset=gb2312" %>
<html>
<head>
<title>Forward动作示例</title>
</head>
<body>
<center><h2>登录成功</h2>
<p>欢迎
<% String User=request.getParameter("User");
out.print(User);
%>
</p>
</body>
</html>
Login.jsp:
<html>
<head>
<title>登录信息</title>
</head>
<body>
<form action="Judgment.jsp" method="post" name="Loginfrm" id="Loginfrm">
<table width="298" border="0" align="center" cellpadding="2" cellspacing="1">
<tr>
<td align="right">用户名:</td>
<td align="left"><input name="User" type="text" size="28"></td>
</tr>
<tr>
<td align="right">密 码:</td>
<td align="left"><input name="Password" type="password" size="30"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="登录">
<input type="reset" value="取消"></td>
</tr>
</table>
</form>
</body>
</html>
posted on 2009-05-27 23:24
天堂露珠 阅读(192)
评论(0) 编辑 收藏 所属分类:
JSP