MyJSP.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
<head>
</head>
<body>
<form action="a1.jsp" method="post">
用户名:<input type="text" name="yonghuming"><br>
密码:<input type="password" name="mima"><br>
<input type="submit" value="提 交">
</form>
</body>
</html>
a1.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
<head>
</head>
<body>
<%String xingming=request.getParameter("yonghuming");
String xuehao=request.getParameter("mima");
if(xingming.equals("huangzesen")&&xuehao.equals("3152052051501")){
%>
<jsp:forward page="success.jsp"/>
<%}else{%>
<jsp:forward page="fail.jsp"/>
<%}%>
</body>
</html>
success.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
</head>
<body>
<%
String ming=request.getParameter("yonghuming");
String hao=request.getParameter("mima");
%>
登陆成功<br>
您输入的信息为:<br>
用户名:<%=ming%><br>
密码:<%=hao%><br>
</body>
</html>
fail.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
<head>
</head>
<body>
<a href="MyJsp.jsp">登陆失败 请重新输入</a>
</body>
</html>