第四周

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>bootstrap案例</title>
<link
    href="http://apps.bdimg.com/libs/bootstrap/3.3.0/css/bootstrap.min.css"
    rel="stylesheet">
<link
    href="//cdn.bootcss.com/font-awesome/4.3.0/css/font-awesome.min.css"
    rel="stylesheet">
<script src="http://apps.bdimg.com/libs/jquery/2.0.0/jquery.min.js"></script>
<script
    src="http://apps.bdimg.com/libs/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/jquery.validate.min.js"></script>
<script type="text/javascript" src="js/message.js"></script>
<style type="text/css">
body {
    background: url(img/4.jpg) no-repeat;
    background-size: cover;
    font-size: 16px;
}

.form {
    background: rgba(255, 255, 255, 0.2);
    width: 400px;
    margin: 100px auto;
}

#login_form {
    display: block;
}

#register_form {
    display: none;
}

.fa {
    display: inline-block;
    top: 27px;
    left: 6px;
    position: relative;
    color: #ccc;
}
<%@ 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>

</head>

<body>
    Please register and enter the verification code!
    <br />
    <form action="dologin.jsp" name="myform" method="post">
        user name:<input type="text" name="uname"><br /><br /> password:<input
            type="password" name="upwd"><br /><br /> Verification code: <INPUT
            style="BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid"
            type=text maxLength=10 size=10 name="validateCode" /> <img id="code"
            style="CURSOR: pointer" src="code.jsp" alt="点击刷新验证码"><br /> <br />
        <input type="submit" value="Login">

    </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"))
        request.getRequestDispatcher("ok.jsp").forward(request,
                response);
    else
        request.getRequestDispatcher("no.jsp").forward(request,
                response);
%>
<%@ page
    import="java.awt.*,java.awt.image.*,java.util.*,javax.imageio.*"%>
<%@ page import="java.io.OutputStream"%>
<%@ page pageEncoding="UTF-8"%>
<%!Color getRandColor(int fc, int bc) {
        Random random = new Random();
        if (fc > 255)
            fc = 255;
        if (bc > 255)
            bc = 255;
        int r = fc + random.nextInt(bc - fc);
        int g = fc + random.nextInt(bc - fc);
        int b = fc + random.nextInt(bc - fc);
        return new Color(r, g, b);
    }%>
<%
    try {
        response.setHeader("Pragma", "No-cache");
        response.setHeader("Cache-Control", "no-cache");
        response.setDateHeader("Expires", 0);
        int width = 85, height = 20;

        BufferedImage image = new BufferedImage(width, height,
                BufferedImage.TYPE_INT_RGB);
        OutputStream os = response.getOutputStream();
        Graphics g = image.getGraphics();
        Random random = new Random();

        g.setColor(getRandColor(200, 250));
        g.fillRect(0, 0, width, height);

        g.setFont(new Font("Times New Roman", Font.PLAIN, 20));
        g.setColor(getRandColor(120, 200));
        for (int i = 0; i < 155; i++) {
            int x = random.nextInt(width);
            int y = random.nextInt(height);
            int xl = random.nextInt(5);
            int yl = random.nextInt(5);
            g.drawLine(x, y, x + xl, y + yl);
        }
        String sRand = "";
        for (int i = 0; i < 5; i++) {
            String chose = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            String rand = String.valueOf(chose.charAt(random
                    .nextInt(chose.length())));
            sRand += rand;
            g.setColor(new Color(20 + random.nextInt(110), 20 + random
                    .nextInt(110), 20 + random.nextInt(110)));
            g.drawString(rand, 15 * i + 6, 16);
        }
        session.setAttribute("code", sRand);
        g.dispose();

        ImageIO.write(image, "JPEG", os);
        os.flush();
        os.close();
        os = null;
        response.flushBuffer();
        out.clear();
        out = pageContext.pushBody();
    } catch (IllegalStateException e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
%>

 

 

 


input[type="text"],input[type="password"] {
    padding-left: 26px;
}

.checkbox {
    padding-left: 21px;
}
</style>
</head>
<body>
    <div class="form row">
        <form class="form-horizontal col-sm-offset-3 col-md-offset-3"
            id="login_form">
            <h3 class="form-title">Login to your account</h3>
            <div class="col-sm-9 col-md-9">
                <div class="form-group">
                    <i class="fa fa-user fa-lg"></i> <input
                        class="form-control required" type="text" placeholder="Username"
                        name="username" autofocus="autofocus" maxlength="20" />
                </div>
                <div class="form-group">
                    <i class="fa fa-lock fa-lg"></i> <input
                        class="form-control required" type="password"
                        placeholder="Password" name="password" maxlength="8" />
                </div>
                <div class="form-group">
                    <label class="checkbox"> <input type="checkbox"
                        name="remember" value="1" /> Remember me </label>
                    <hr />
                    <a href="login.jsp" id="register_btn" class="">Create an
                        account to login </a>
                </div>
            </div>
        </form>
    </div>
</body>
</html>

第四周

 

上一篇:【每日蓝桥】51、一七年省赛Java组真题“分巧克力”


下一篇:第3章 3.1 Scanner类