zoukankan      html  css  js  c++  java
  • 【JSP】简单登陆界面

    学生登陆查询系统

         1 程序的主要功能及特点

    实现一个登录界面的基本功能,具体要求:

    • 登录界面login.jsp含有表单,用户能够输入用户名和密码,并提交表单给verify.jsp。
    • Verify.jsp读取表单信息,并验证接收的用户名和密码是否与verify.jsp内置的相应变量值一致。
    • 如果一致,则转向页面success.jsp,显示"成功登录"并可以手动选择要查询的系统。
    • 如果不一致,则转向页面failure.jsp,显示"登录失败"并手动返回。
    • 本系统默认:用户名14347119密码wuxing为正确。

      2 程序部署及运行截图和相应说明(手工部署)

      部署

      • 成功登陆后可以选择登陆某一查询系统,见下图
      • 不成功登陆提示错误并返回,见下图

      SUCCESS LOGIN

      FAILURE LOGIN

      3 程序源代码

      login.jsp

       1 <%@ page language="java" contentType="text/html; charset=UTF-8"
       2     pageEncoding="UTF-8"%>
       3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
       4 <html>
       5 <head>
       6 <title>loginPage</title>
       7 </head>
       8 <body bgcolor=AliceBlue >
       9 <form name="loginForm" method="post" action="verify.jsp">
      10 <center>
      11 <font size=6>学生微教务</font>
      12 </center>
      13 <center>
      14 <table>
      15 <tr>
      16 <td height="40" weight="100">UserName<input type="text" name="userName" id="userName"></td>
      17 </tr>
      18 <tr>
      19 <td height="40" weight="100">Password<input type="password" name="password" id="password"></td>
      20 </tr>
      21 <tr>
      22 <td><input type="submit" value="login" style="background-color:white"> <input type="reset" value="reset" style="background-color:yellow"></td> 
      23 </tr>
      24 </table>
      25 </center>
      26 </form>
      27 </body>
      28 </html> 

      verify.jsp

       1 <%@ page language="java" contentType="text/html; charset=UTF-8"
       2     pageEncoding="UTF-8"%>
       3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
       4 <html>
       5 <head>
       6 <title>Authentication</title>
       7 </head>
       8 <body>
       9 <% 
      10 request.setCharacterEncoding("UTF-8");
      11 String name = request.getParameter("userName");
      12 String password = request.getParameter("password");
      13 if(name.equals("14347119")&& password.equals("wuxing")) {
      14 %>
      15 <jsp:forward page="success.jsp">
      16 <jsp:param name="userName" value="<%=name%>"/></jsp:forward>
      17 <%}
      18 else{
      19 %>
      20 <jsp:forward page="failure.jsp"></jsp:forward>
      21 <%} 
      22 %>
      23 </body>
      24 </html>

       

      success.jsp

       1 <%@ page language="java" contentType="text/html; charset=UTF-8"
       2     pageEncoding="UTF-8"%>
       3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
       4 <html>
       5 <head>
       6 <title>Login Success</title>
       7 </head>
       8 <body bgcolor=AliceBlue>
       9 <form name="SUCCESS" method="post" action="JMP.jsp">
      10 <center>
      11 <%request.setCharacterEncoding("UTF-8");
      12 String name = request.getParameter("userName");
      13 out.println("Welcome:"+name);%><BR>
      14 </center>
      15 <center>
      16 <BR><font size="6">Score Query System</font><BR>
      17 <BR><font size="4">Please select one item to check</font>
      18 <Select name="grade" >
      19               <Option selected value="http://wjw.sysu.edu.cn">Academic performance</option>
      20               <Option value="http://cet.99sushe.com">CET-4 & CET-6</option>
      21               <Option value="http://chaxun.neea.edu.cn/examcenter/query.cn?op=doQueryCond&pram=results&sid=300"> NCRE</option>
      22          </Select> 
      23 <BR><BR> <Input type="submit" value="submit" name="submit">
      24 </center>
      25 </body>
      26 </html>

       

      failure.jsp

       1 <%@ page language="java" contentType="text/html; charset=UTF-8"
       2     pageEncoding="UTF-8"%>
       3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
       4 <html>
       5 <head>
       6 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
       7 <title>Login Failure</title>
       8 </head>
       9 <body bgcolor="Aliceblue">
      10 <center><font size="4">
      11 Incorrect username or password! Please return and try again. 
      12 <BR><A href="login.jsp" >return
      13 </font>
      14 </center>
      15 </body>
      16 </html>

      JMP.JSP(用于跳转网站页面)

       1 <%@ page language="java" contentType="text/html; charset=UTF-8"
       2     pageEncoding="UTF-8"%>
       3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
       4 <html>
       5 <head>
       6 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
       7 <title>JMP</title>
       8 </head>
       9 <body>
      10  <% String s=request.getParameter("grade"); 
      11  response.sendRedirect( s);  %>     
      12 </body>
      13 </html>

       

  • 相关阅读:
    kicad 基本操作
    RedHat centos中的上传下推脚本
    使用Node.js爬虫存储MySQL数据库
    解决vue和vue-template-compiler版本不同报错的问题
    Vue组件通信(父子组件通信)-学习笔记
    git 简单操作
    错误解决:redis.exceptions.ResponseError: unknown command 'SENTINEL'
    nginx做泛域名解析的域名的正则判断
    postman对字符串进行base64编码方法和变量的使用
    pymysql报错OperationalError: (2013, 'Lost connection to MySQL server during query')
  • 原文地址:https://www.cnblogs.com/tenderwx/p/5338671.html
Copyright © 2011-2022 走看看