zoukankan      html  css  js  c++  java
  • JSP内置对象阶段案例

    1.login2:

    <%@ 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>
    <base href="<%=basePath%>">
    
    <title>My JSP 'login2.jsp' starting page</title>
    
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
        <link rel="stylesheet" type="text/css" href="styles.css">
        -->
    
    </head>
    
    <body>
        <form action="JSP/login2_temp.jsp" method="post">
            <table>
                <tr>
                    <td>用户名:</td>
                    <td><input type="text" name="username" />
                    </td>
                </tr>
                <tr>
                    <td>密码</td>
                    <td><input type="text" name="password" /></td>
                </tr>
                <tr>
                <td><input  type="submit"/></td></tr>
            </table>
        </form>
    </body>
    </html>

    2.login_temp:(注意判断是否为空再加入session中)

    <%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
    <%
        String path = request.getContextPath();
        String basePath = request.getScheme() + "://"
                + request.getServerName() + ":" + request.getServerPort()
                + path + "/";
        String username = "";
        String password = "";
        username = request.getParameter("username");
        password = request.getParameter("password");
        if(username!=null){
            session.setAttribute("loginuser", username);
        }
        if("admin".equals(username)&&"admin".equals(password)){
            request.getRequestDispatcher("login2_success.jsp").forward(request, response);
        }else{
            response.sendRedirect("login2_failure.jsp");
        }
        
    %>

    3.login_seccess:

    <%@ 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>
        <base href="<%=basePath%>">
        
        <title>My JSP 'login2_success.jsp' starting page</title>
        
        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">    
        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        <meta http-equiv="description" content="This is my page">
        <!--
        <link rel="stylesheet" type="text/css" href="styles.css">
        -->
    
      </head>
      
      <body>
       <h1>欢迎<%=session.getAttribute("loginuser") %> 登陆成功</h1>
      </body>
    </html>

    4.login2_failure:

    <%@ 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>
        <base href="<%=basePath%>">
        
        <title>My JSP 'login2_failure.jsp' starting page</title>
        
        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">    
        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        <meta http-equiv="description" content="This is my page">
        <!--
        <link rel="stylesheet" type="text/css" href="styles.css">
        -->
    
      </head>
      
      <body>
        <h1>登陆失败,请检查您的用户名和密码</h1>
      </body>
    </html>
  • 相关阅读:
    Linux常用命令总结
    Oracle 11g (服务器类)安装与卸载,解锁scott账户,环境不满足最低要求问题解决
    变态青蛙跳台阶
    1.2、(数据库的定义)、(数据库管理系统)
    数据库概论:1、(数据库系统概述:数据的定义、数据和语义密不可分、数据之间的联系)
    3.1、2、3(什么是springAOP)(AOP术语)(JDK动态代理)
    2.9(基于XML的两种装配实例化对象的方式)、(基于annotation的装配方式)、(自动装配)
    2.8(Bean的生命周期)
    2.5(作用域的种类)、(singleton作用域)、(prototype作用域)
    2.2(构造器实例化)【此方法在项目中较为常用】、(静态工厂实例化)、(实例工厂实例化)
  • 原文地址:https://www.cnblogs.com/sunxiaoyan/p/8543263.html
Copyright © 2011-2022 走看看