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>
        <base href="<%=basePath%>">
        
        <title>My JSP 'index.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>
      登录<br/>
       <form action="zhuanfa.jsp" name="myform" method="post" >
       用户名:<input type="text" name="uname"><br/>
       密码:<input type="password" name="upwd"><br/>  
       <input type="submit" value="登录">
       </form>
       
       
       
      </body>
    </html>

    转发

    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%
        //获取登录的用户名
        String name = request.getParameter("uname");
        //获取登录密码
        String pwd = request.getParameter("upwd");
        //判断
    
        if (name.equals("zs") && pwd.equals("123"))
            //转发到ok页面
            request.getRequestDispatcher("ok.jsp").forward(request,response);
        else
            //转发到no页面 
            request.getRequestDispatcher("no.jsp").forward(request,response);
    %>

    登陆成功

    <%@ 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 'index.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 style="color: red">登录成功</h1>
       
       
      </body>
    </html>
  • 相关阅读:
    java 传入多个参数时报"Parameter 'XXX' not found. Available parameters are [arg1, arg0, param1,..." 解决方案
    java 判断int类型为空
    scp 传输下载
    自己开发的网页在跳转至微信公众号文章后,点击微信的返回,无法返回原网页
    nginx下Thinkphp 隐藏index.php
    ubuntu常见错误–Could not get lock /var/lib/dpkg/lock解决
    apt-get update 和 upgrade 的区别
    php 取某一日期的前一天
    PHP 统计数组中所有的值出现的次数 array_count_values 函数
    pandas之表格样式
  • 原文地址:https://www.cnblogs.com/hx1999/p/14590145.html
Copyright © 2011-2022 走看看