zoukankan      html  css  js  c++  java
  • jsp第五次作业

    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
       <title>登录界面</title>
       <style type="text/css">
       body{font-size:16px;}
       </style>
       <script type="text/javascript">
      function mycheck(){
      if(form1.userName.value==""){
      alert("用户名不能为空,请输入用户名!");
      form1.userName.focus();
      return;
      } 
      if(form1.password.value==""){
      alert("密码不能为空,请输入密码!");
      form1.password.focus();
      return;
      }
      if(form1.validationCode.value==""){
      alert("验证码不能为空,请输入验证码!");
      form1.validationCode.focus();
      return;
      }
      if(form1.validationCode.value != form1.validationCode1.value){
      alert("请输入正确的验证码!!");
      form1.validationCode.focus();
      return;
        }
        form1.submit1();
      }
       </script>
      </head>
      
      <body bgcolor="pink">
      <form action="loginCkeck.jsp" name="form1" method="post">
      用户名:<input type="text" name="userName" size="16">
      <br>密    码:
      <input type="password" name="password" size="18">
      <br>
      验证码:<input type="text" name="validationgCode" 
      onKeyDown="if(event.keyCode==13){form1.submit.focus();}" size="6">
      <%
     int intmethod1=(int) ((((Math.random())*11))-1) ;
     int intmethod2=(int) ((((Math.random())*11))-1) ;
     int intmethod3=(int) ((((Math.random())*11))-1) ;
     int intmethod4=(int) ((((Math.random())*11))-1) ;
      String intsum=intmethod1+""+intmethod2+intmethod3+intmethod4;
       %>
      <!-- 设置隐藏域,验证比较时使用 -->
      <input type="hidden" name="validationCode1" value="<%=intsum %>">
        <img src="../image/<%=intmethod1%>.gif">
        <img src="../image/<%=intmethod2%>.gif">
        <img src="../image/<%=intmethod3%>.gif">
        <img src="../image/<%=intmethod4%>.gif">
        <br>
      <input type="submit" name="submit1" value="登录" onClick="mycheck()">
       
      <input type="rest" value="重置">
      </form>
       
      </body>
    </html>
    

      

    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
       <title>处理登录页面的数据</title> 
      </head>
      <body bgcolor="pink">
      <%
      request.setCharacterEncoding("UTF-8");
      String name=request.getParameter("userName");
      String password=request.getParameter("password");
      if(request.getParameter("validationCode1").equals(request.getParater("validationCode")))
      {
      if(name.equals("pdy")&&(password.equals("666666"))){
      session.setAttribute("userName",name);
      response.sendRedirect(main.jsp);
        
      }else{
      
      response.sendRedirect("login.jsp");
        }
      }else{
      
      response.sendRedirect("login.jsp");
      }
        %>
        
      </body>
    </html>
    

      

    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <title>系统主页面</title>
      </head>
      
      <body bgcolor="pink">
      <%
      String name=(String)session.getAttribute("userName");
       %>
       您好<%=name %>,欢迎您访问!<br>
       <a herf="exit.jsp">[退出系统]</a>
      </body>
    </html>
    

      

    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <title>退出系统</title>
      </head>
      
      <body >
     <% 
     session.invalidate();
     response.sendRedirect("login.jsp");
     %>
      </body>
    </html>
    

      

  • 相关阅读:
    windows live writer backup
    SQL SERVER单独安装
    VS异常--未找到与约束 ContractName Microsoft.VisualStudio.Language.Intellisense.IGlyphService RequiredTypeIdentity
    ASP.NET之报表--RDLC(一)---附源码
    尚未指定报表“Report1”的报表定义
    人月神话
    [LeetCode]Reverse Nodes in k-Group
    [LeetCode]Divide Two Integer
    [LeetCode]Minimum Path Sum
    [LeetCode]Regular Expression Matching
  • 原文地址:https://www.cnblogs.com/zz2333/p/12709265.html
Copyright © 2011-2022 走看看