JSP登陆

login.jsp

<%@ page language="java" contentType="text/html; charset=GB2312"
    pageEncoding="GB2312"%>
<%@ page import="java.util.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title>登录页面</title>
</head>
<body>
  <form name="loginForm" method="post" action="judgeUser.jsp">
    <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>


judgeUser.jsp

<%@ page language="java" contentType="text/html; charset=GB2312"
    pageEncoding="GB2312"%>
<%@ page import="java.util.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title>身份验证</title>
</head>
<body>
  <%
    request.setCharacterEncoding("GB2312");
    String name = request.getParameter("userName");
    String password = request.getParameter("password");
    if(name.equals("abc")&& password.equals("123")) {
      
  %>
  <jsp:forward page="afterLogin.jsp">
     <jsp:param name="userName" value="<%=name%>"/>
  </jsp:forward>
  <%
   }
   else {
  %>
  <jsp:forward page="login.jsp"/>
  <%
   }
  %>
</body>
</html> 


after.jsp

<%@ page language="java" contentType="text/html; charset=GB2312"
    pageEncoding="GB2312"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
 <title>登录成功</title>
</head>
<body>
  <%
   request.setCharacterEncoding("GB2312");
   String name = request.getParameter("userName");
   out.println("欢迎你:" + name);
  %>
</body>
</html> 


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值