易截截图软件、单文件、免安装、纯绿色、仅160KB

JSP彩色验证码

产生验证码图片的文件-----image.jsp
<%@ 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(new Color());
//g.drawRect(0,0,width-1,height-1);
// 随机产生155条干扰线,使图象中的认证码不易被其它程序探测到
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);
}
// 取随机产生的认证码(4位数字)
String sRand="";
for (int i=0;i<4;i++){
    String rand=String.valueOf(random.nextInt(10));
    sRand+=rand;
    // 将认证码显示到图象中
 &nb


相关文档:

Tomcat JSP Web 开发中的乱码问题小结


1. 静态页面的乱码问题
文件的编码和浏览器要显示的编码不一致。
1) 检查文件原始的编码, 可以用记事本打开, 然后选择另存为来看;
2) 给当前页面加入一个指令来建议浏览器用指定的编码来显示文件字符内容.
<meta http-equiv="content-type" content="text/html; charset=GBK">
3) 如果系统是英文XP,没装东亚字 ......

JSP如何设置Cookie和删除Cookie

很多例如登录或者注销登录的地方需要使用到Cookie,今天学到在JSP中如何操作Cookie分享下
4.Cookie类常用的方法
1.setValue()/getValue() —>获取cookie对象的值。
2.getName()—>获取cookie对象的名称,循环的时候可以有选择的使用Cookie
3.setMaxAge()/getMaxAge()—>设置或获取cookie对象有 ......

jsp笔记

今天重新整理电脑,找到一个文件,看了下日期(2006.10.21) ,怕不小心再丢了,存到网上来晒晒。 
0或1个package  设定类所在包
0或多个import  导入必要类
script     手稿, 手迹, 剧本, 考生的笔试卷, 原本
alert      v.提防的, 警惕的 n.警惕, ......

关于jsp的基本说明

<%@ page contentType="text/html; charset=GB2312" %>
<%@ page errorPage="jsp3_error.jsp" %>
<%@ page import="java.util.*,java.io.*" %>
<html>
<head>
<title>
jsp综合应用
</title>
</head>
<jsp:useBean id="jsp3BeanId" scope="session" class="pan ......

JSP中的相对路径解惑

简单示例
JSP页面中,我们经常有引用各种图片等资源,例如下面的jsp片段中
<div class="main">
      <a href="http://www.sina.com.cn/abc.htm">
              <strong>我的档案</strong>
&nbs ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号