Java web 练习题集合

在界面1中输入账号和密码,进行登录。若账号和密码正确,则认为登录到界面2,在界面2中输入姓名,提交后,在界面3中输出姓名和密码。

<%@ page language="java" contentType="text/html; charset=gb2312"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  
  <body>
       欢迎登录
  <script type="text/javascript">
   
      function validate(){
           if(loginForm.account.value!=""&&loginForm.password.value!=""&&loginForm.account.value==loginForm.password.value){
             alert("登录成功");
               loginForm.submit();
               return;
           }else{
              alert("登录失败");
              return;
           }
          }
          
  </script>  
  <form name="loginForm" action="ans05_1.jsp" >
    请输入账号:<input name="account" type="text"><br>
    请输入密码:<input name="password" type="password"><br> 
 <input type="button" value="登录" onClick="validate()">
  </form>
 
  </body>
</html>
<%@ page language="java" contentType="text/html; charset=gb2312"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  
  <body>
      <%
        String account1=request.getParameter("account");
      %>
     
  <form action="ans05_2.jsp" method="post">
  <input name="useraccount" type="hidden" value="<%=account1%>">
    已登录成功,请输入用户姓名:<input name="username" type="text"><br>
  <input type="submit" value="确认">
  </form>
   
  </body>
</html>
<%@ page language="java" contentType="text/html; charset=gb2312"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  
  <body>
  <%
     String account2=request.getParameter("useraccount");
     String name=request.getParameter("username");
     out.println("用户的账号:"+account2);
     out.println("用户的姓名:"+name);
   %>
  </body>
</html>

 

 

 

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值