• 大小: 2.33MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-10-01
  • 语言: Java
  • 标签: 其他  

资源简介

本系统采用Jsp+Servlet+JDBC的架构编写,表现层页面采用Jstl1.1和EL表达式语言进行数据的表现,部分简单功能功能采用了Ajax技术,开发周期5天(有点长),其中图片上传采用apache的FileUpload组件,并且进行了简易封装

资源截图

代码片段和文件信息

package hbu.david.cmc;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Random;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageEncoder;

/**
 * @author zxub 2006-5-25 下午02:50:29
 */
public class VerifyCode
{
//随机数对象
    static Random r = new Random();
    //预定义的字符串
    //static String ssource = “ABCDEFGHIJKLMNOPQRSTUVWXYZ“ + “0123456789“;
    static String ssource = “abcdefghijklmnopqrstuvwxyz“ + “0123456789“;
    ///把字符串转换成为字节数组
    static char[] src = ssource.toCharArray();
    //预定义的验证码长度
    private int codeLength = 4;

    private HttpServletRequest request = null;
    private HttpServletResponse response = null;
    
    /***********************
     * 构造函数
     * 默认的验证码长度为codeLength
     * @param request
     * @param response
     * **********************
     */
    public VerifyCode(HttpServletRequest request HttpServletResponse response)
    {
        this.request = request;
        this.response = response;
        String code = getCode(this.codeLength);
        this.createImage(code);
    }
    /*****************************
     * 构造函数
     * 验证码长度自己设置codeLength 
     * @param request
     * @param response
     * @param codeLength
     */
    public VerifyCode(HttpServletRequest request HttpServletResponse response
            Integer codeLength)
    {
        this.codeLength = codeLength.intValue();
        this.request = request;
        this.response = response;
        String code = getCode(this.codeLength);
        this.createImage(code);
    }

    /**
     * 产生随机字符串
     * 长度为length
     * @param length
     * @return
     */
    private String getCode(int length)
    {
        char[] buf = new char[length];
        int rnd;
        for (int i = 0; i < length; i++)
        {
            rnd = Math.abs(r.nextInt()) % src.length;

            buf[i] = src[rnd];
        }
        return new String(buf);
    }

    /**
     * 给定范围获得随机颜色
     * 
     * @param fc
     * @param bc
     * @return
     */
    private 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);
    }

    /**
     * 调用该方法将得到的验证码生成图象
     * 
     * @param sCode 验证码
     * @return
     */
    private void createImage(String sCode)
    {
     //设置ContentType类型为 image/jpeg
        this.response.setContentType(“image/jpeg“);
        // 设置页面不缓存
        this.re

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        533  2007-08-14 19:53  20070826发布\OpenAjaxAlbum\.classpath

     文件        858  2007-08-14 19:53  20070826发布\OpenAjaxAlbum\.project

     文件        141  2007-08-21 10:22  20070826发布\OpenAjaxAlbum\.settings\org.eclipse.core.resources.prefs

     文件        330  2007-08-14 19:53  20070826发布\OpenAjaxAlbum\.settings\org.eclipse.jdt.core.prefs

     文件        364  2007-08-14 19:53  20070826发布\OpenAjaxAlbum\.settings\org.eclipse.jst.common.project.facet.core.prefs

     文件        414  2007-08-14 19:53  20070826发布\OpenAjaxAlbum\.settings\org.eclipse.wst.common.component

     文件        269  2007-08-14 19:53  20070826发布\OpenAjaxAlbum\.settings\org.eclipse.wst.common.project.facet.core.xml

     目录          0  2007-08-26 09:50  20070826发布\OpenAjaxAlbum\.settings

     文件       1865  2007-08-24 09:04  20070826发布\OpenAjaxAlbum\build\classes\hbu\david\cmc\bean\Category.class

     文件       1118  2007-08-24 09:04  20070826发布\OpenAjaxAlbum\build\classes\hbu\david\cmc\bean\CategoryPassword.class

     文件       1590  2007-08-24 09:04  20070826发布\OpenAjaxAlbum\build\classes\hbu\david\cmc\bean\Comment.class

     文件       2292  2007-08-24 09:04  20070826发布\OpenAjaxAlbum\build\classes\hbu\david\cmc\bean\Photo.class

     文件       1701  2007-08-24 09:04  20070826发布\OpenAjaxAlbum\build\classes\hbu\david\cmc\bean\UserInfo.class

     目录          0  2007-08-26 09:50  20070826发布\OpenAjaxAlbum\build\classes\hbu\david\cmc\bean

     文件       2137  2007-08-24 09:04  20070826发布\OpenAjaxAlbum\build\classes\hbu\david\cmc\dao\DatabaseBean.class

     目录          0  2007-08-26 09:50  20070826发布\OpenAjaxAlbum\build\classes\hbu\david\cmc\dao

     文件       2012  2007-08-24 09:04  20070826发布\OpenAjaxAlbum\build\classes\hbu\david\cmc\http\MyHttpServlet.class

     文件        982  2007-08-24 09:04  20070826发布\OpenAjaxAlbum\build\classes\hbu\david\cmc\http\ServletEncoding.class

     目录          0  2007-08-26 09:50  20070826发布\OpenAjaxAlbum\build\classes\hbu\david\cmc\http

     文件       2331  2007-08-26 09:48  20070826发布\OpenAjaxAlbum\build\classes\hbu\david\cmc\servlet\AddCategoryServlet.class

     文件       1909  2007-08-24 09:04  20070826发布\OpenAjaxAlbum\build\classes\hbu\david\cmc\servlet\AddCommentServlet.class

     文件       3750  2007-08-24 17:23  20070826发布\OpenAjaxAlbum\build\classes\hbu\david\cmc\servlet\AddPhotoServlet.class

     文件       2671  2007-08-24 09:04  20070826发布\OpenAjaxAlbum\build\classes\hbu\david\cmc\servlet\AddUserServlet.class

     文件       2201  2007-08-24 09:04  20070826发布\OpenAjaxAlbum\build\classes\hbu\david\cmc\servlet\ChangePasswordServlet.class

     文件       1907  2007-08-24 09:04  20070826发布\OpenAjaxAlbum\build\classes\hbu\david\cmc\servlet\CheckUsernameExist.class

     文件       2109  2007-08-26 09:48  20070826发布\OpenAjaxAlbum\build\classes\hbu\david\cmc\servlet\DeleteCategoryServlet.class

     文件       1273  2007-08-24 09:04  20070826发布\OpenAjaxAlbum\build\classes\hbu\david\cmc\servlet\DeleteCommentById.class

     文件       2057  2007-08-24 20:08  20070826发布\OpenAjaxAlbum\build\classes\hbu\david\cmc\servlet\DeletePhotoServlet.class

     文件       2312  2007-08-26 09:48  20070826发布\OpenAjaxAlbum\build\classes\hbu\david\cmc\servlet\GetCategoriesServlet.class

     文件       2243  2007-08-24 09:28  20070826发布\OpenAjaxAlbum\build\classes\hbu\david\cmc\servlet\GetCommentAdminServlet.class

............此处省略157个文件信息

评论

共有 条评论