81,094
社区成员
发帖
与我相关
我的任务
分享
<%@ page language="java" import="java.util.*" contentType="text/html; charset=gbk"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="css/style.css"/>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="css/font-awesome.min.css" />
<link rel="stylesheet" type="text/css" href="css/buttons.css" />
<!--<link rel="stylesheet" type="text/css" href="css/bootstrap-datetimepicker.css" />-->
<!--<link rel="stylesheet" type="text/css" href="css/bootstrap-datetimepicker.min.css" />-->
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery-2.2.2.min.js"></script>
<!--<script src="js/bootstrap-datetimepicker.min.js"></script>-->
<title></title>
<script>
function loadimage(){
document.getElementById("randImage").src = "image.jsp?"+Math.random();
}
</script>
</head>
<body>
<header style="text-align: center;">
<h1>欢迎</h1>
</header>
<form class="form-horizontal log-or-sign col-xs-12 col-sm-6 col-md-4 col-lg-3" method="post" action="<%=request.getContextPath()%>/Login">
<fieldset>
<div id="legend" class="">
<legend class="">用户登陆</legend>
</div>
<div class="control-group">
<label class="col-xs-4 control-label" for="uname">用户名</label>
<div class="col-xs-8">
<input type="text" placeholder="用户名" class="form-control" name="username" required="" id="uname">
<p class="help-block"></p>
</div>
</div>
<div class="control-group">
<label class="col-xs-4 control-label" for="pwd">密码</label>
<div class="col-xs-8 controls">
<input type="password" placeholder="密码" class="form-control" name="password" required="" id="pwd">
<p class="help-block"></p>
</div>
</div>
<div class="control-group">
<label class="col-xs-4 control-label" for="select">用户身份</label>
<div class="col-xs-8 controls">
<select class="form-control" id="select">
<option value="1">员工</option>
<option value="2">管理员</option>
</select>
<p class="help-block"></p>
</div>
</div>
<div class="control-group">
<label class="col-xs-4 control-label" for="rand">验证码</label>
<div class="col-xs-8 controls">
<input type="text" placeholder="验证码" class="form-control" name="rand" required="" id="rand">
<p class="help-block"></p>
</div>
</div>
<div class="control-group">
<label class="col-xs-4 control-label" for="randImage"></label>
<div class="col-xs-8 controls" >
<img class="col-xs-9" name="randImage" id="randImage" src="image.jsp" onclick="loadimage()">
<p class="help-block"></p>
</div>
</div>
<h1> </h1>
<!--<label for="aa">日期:</label><input id="aa" type="date" value="2014-01-13"/>
<input type="text" value="2012-05-15 21:05" id="datetimepicker">
<script>$('#datetimepicker').datetimepicker({format: 'yyyy-mm-dd hh:ii'});</script> -->
<div class="control-group">
<div class="col-xs-6">
<input type="submit" name="submit" class="button button-glow button-border button-rounded button-primary" value="确定"></input>
</div>
<div class="col-xs-6">
<input type="reset" name="reset" class="button button-glow button-border button-rounded button-primary" value="重置"></input>
</div>
</div>
</fieldset>
</form>
</body>
</html>
<%@ page contentType="image/jpeg" import="java.awt.*, java.awt.image.*,java.util.*,javax.imageio.*" %>
<%!
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);
}
%>
<%
response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires", 0);
int width=60, height=20;
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
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,18));
g.setColor(getRandColor(160,200));
for (int i=0;i<155;i++)
{
int x = random.nextInt(width);
int y = random.nextInt(height);
int xl = random.nextInt(12);
int yl = random.nextInt(12);
g.drawLine(x,y,x+xl,y+yl);
}
String sRand="";
for (int i=0;i<4;i++){
String rand=String.valueOf(random.nextInt(10));
sRand+=rand;
g.setColor(new Color(20+random.nextInt(110),20+random.nextInt(110),20+random.nextInt(110)));
g.drawString(rand,13*i+6,16);
}
session.setAttribute("rand",sRand);
g.dispose();
ImageIO.write(image, "JPEG", response.getOutputStream());
%>