zoukankan      html  css  js  c++  java
  • 第六周作业

    <%@ 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></title>
        <style type="text/css">
    body{ font-size:13px; font-family:"宋体";}               
    body,form,input,p{ padding:0; margin:0; border:0;}      
    form{
        300px;
        height:200px;
        padding-top:20px;
        margin:60px auto;                   
        background:#2aa 6ea;              
        border-radius:30px;                 
        border:2px solid #4faccb;
    }
    p{
        margin-top:20px;
        text-align:center;
    }                 
    p span{
        30px;
        display:inline-block;
        text-align:right;
        }               
    .num,.pass{                             
        152px;                                    
        height:18px;                               
        border:1px solid #38a1bf;
        padding:2px 2px 2px 22px;
    }
    .num{                                   
         background:url(images/1.jpg) no-repeat 5px center #FFF;
         color:#999;
    }                   
    .pass{                                                                              
         background:url(images/2.jpag) no-repeat 5px center #FFF;
    }
    .btn01,.btn02{
        60px;
        height:25px;
        border-radius:3px;                     
        border:1px solid #6b5d50;
        margin-left:30px;
        }
    .btn02{ background:#3aa7ea;}                 
    </style>
      </head>
        
      <body>
        <form action="dologin.jsp" method="post" autocomplete="on"> 
        <p>
            <span>账号:</span>
            <input type="text" name="user" class="num"  />
        </p>
        <p>
             <span>密码:</span>
             <input type="password" name="password" class="pass"/>
        </p>
        <p><span>验证码</span><input type="text" name="code"/>qwer</p>
          
        <p>
            <input type="submit" class="btn02" value="登录"/>
       </p>
        
        </form>
             
      </body>
    </html>
    <%@page import="java.sql.ResultSet"%>
    <%@page import="java.sql.PreparedStatement"%>
    <%@page import="java.sql.DriverManager"%>
    <%@page import="java.sql.Connection"%>
    <%@ page language="java" contentType="text/html; charset=utf-8"
        pageEncoding="utf-8"
        import=" javax.servlet.http.HttpSession"
        %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <%
    request.setCharacterEncoding("UTF-8");
    response.setContentType("text/html;charset=utf-8");
    response.setCharacterEncoding("UTF-8");
     HttpSession s = request.getSession();
     
     String username = request.getParameter("username");
     String password1 = request.getParameter("password");
         Class clazz = Class.forName("com.mysql.jdbc.Driver");
        String url = "jdbc:mysql://localhost:3306/school";
        String user = "root";
        String password = "root";
        Connection conn = DriverManager.getConnection(url, user, password);
        PreparedStatement ps = conn.prepareStatement("select uname,upwd from user where uname = ? and upwd = ?");
        ps.setString(1, username);
        ps.setString(2, password1);
        ResultSet rs = ps.executeQuery();
        if(rs.next()){
             session.setAttribute("username", username);
             session.setAttribute("password", password1);
             response.sendRedirect("/school/success.jsp");
        }else{
            response.sendRedirect("/school/loginyanzheng2.jsp");
        }
     
     
      
    %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Insert title here</title>
    </head>
    <body>
     
    </body>
    </html>
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <html>
    <head>
        <title>title</title>
    </head>
    <body>
     
    <%
        String username = (String) request.getSession().getAttribute("username");
    %>
    欢迎你<%=username%>
    </body>
    </html>
  • 相关阅读:
    vue多个自定义组件动态显示
    vue弹出多个弹框,并可以拖动弹框
    localStorage和sessionStorage
    Sharepoint ListTemplateId
    SharePoint 上传文档太大 无法上传
    Stream Byte[] 转换
    C#转义字符 单引号 双引号 换行 回车 斜杠
    c#中如何获取本机用户名、MAC地址、IP地址、硬盘ID、CPU序列号、系统名称、物理内存
    SharePoint Content Type ID's
    Visual Studio Tip: Get Public Key Token for a Strong Named Assembly 添加强命名 获取强命名值
  • 原文地址:https://www.cnblogs.com/z118127/p/14649199.html
Copyright © 2011-2022 走看看