jsp验证码
来源:互联网 发布:php判断是否为全空格 编辑:程序博客网 时间:2024/05/07 08:39
常见的加减号验证码
<%@ page language="java" contentType="image/jpeg; charset=utf-8"
pageEncoding="utf-8"%><%@page import="java.awt.*,java.awt.image.*,javax.imageio.ImageIO,java.util.Random" %>
<%
int width = 100, height = 20;
BufferedImage image = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);
Graphics g = image.getGraphics();
Random random = new Random();
g.setColor(Color.WHITE);
g.fillRect(0, 0, width, height);
g.setFont(new Font("Times New Roman", Font.PLAIN, 18));
g.setColor(Color.BLACK);
int a = random.nextInt(10)+10;//可以选择其他
int b = random.nextInt(10);//同上
String[] opts = new String[]{"+","-"};//加 减
String opt = opts[random.nextInt(2)];
int yanZhengMa = 0;// 四位随机数字码
if(opt.equals("+")){
yanZhengMa = a+b;
}else{
yanZhengMa = a-b;
}
g.drawString(a+"", 6, 16);
g.drawString(opt, 13*2 + 6, 16);
g.drawString(b+"", 13 * 3 + 6, 16);
g.drawString("=", 13 * 5 + 6, 16);
request.getSession().setAttribute("yanzhengma", yanZhengMa+"");
g.dispose();
ServletOutputStream os =response.getOutputStream();
ImageIO.write(image, "JPEG", os);
//防止报错
out.clear();
out = pageContext.pushBody();
%>
- jsp+servlet验证码验证
- JSP彩色验证码
- JSP彩色验证码
- JSP彩色验证码
- JSP彩色验证码
- JSP彩色验证码
- JSP实现验证码
- JSP彩色验证码
- JSP彩色验证码
- JSP彩色验证码
- JSP彩色验证码
- JSP彩色验证码
- JSP彩色验证码
- JSP彩色验证码
- 验证码JSP
- JSP生成验证码
- JSP彩色验证码
- jsp 验证码
- cocos2dx配置VS13开发环境问题
- Java正则表达式实现web端输入验证
- cocos2d-x 使用schedule实现倒计时
- 搜狐研发
- 1012 A + B的输入输出练习(三)
- jsp验证码
- 第十三周上机实践项目——最大公约数
- 如何从电脑上直接下载谷歌Play上的安卓应用
- HDU 2031 - 进制转换
- node.js的event loop
- 搜狗软开
- 能说明你的Javascript技术很烂的五个原因
- 【安卓】如何使用Loaders
- 创新工场