预览加载中,请您耐心等待几秒...
1/9
2/9
3/9
4/9
5/9
6/9
7/9
8/9
9/9

在线预览结束,喜欢就下载吧,查找使用更方便

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

第页共NUMPAGES9页 HYPERLINK"http://wolfandlili.javaeye.com/blog/684920"java验证码代码(转) 产生图片servlet importjava.awt.Color; importjava.awt.Font; importjava.awt.Graphics2D; importjava.awt.image.BufferedImage; importjava.util.Random; importjavax.imageio.ImageIO; importjavax.servlet.ServletException; importjavax.servlet.ServletOutputStream; importjavax.servlet.http.HttpServlet; importjavax.servlet.http.HttpServletRequest; importjavax.servlet.http.HttpServletResponse; importjavax.servlet.http.HttpSession; /** *Packagename:com.skcc.sample.actionFilename:VerifyCodeServlet.java *Author:AdministratorDate:2008-9-4Description:VerifyCodeServlet */ publicclassVerifyCodeServletextendsHttpServlet{ /** * */ privatestaticfinallongserialVersionUID=1L; /** *验证码图片的宽度。 */ privateintwidth=60; /** *验证码图片的高度。 */ privateintheight=20; /** *验证码字符个数 */ privateintcodeCount=4; /** *xx */ privateintxx=0; /** *字体高度 */ privateintfontHeight; /** *codeY */ privateintcodeY; /** *codeSequence */ char[]codeSequence={'A','B','C','D','E','F','G','H','I','J', 'K','L','M','N','O','P','Q','R','S','T','U','V','W', 'X','Y','Z','0','1','2','3','4','5','6','7','8','9'}; /** *初始化验证图片属性 */ publicvoidinit()throwsServletException{ //从web.xml中获取初始信息 //宽度 StringstrWidth=this.getInitParameter("width"); //高度 StringstrHeight=this.getInitParameter("height"); //字符个数 StringstrCodeCount=this.getInitParameter("codeCount"); //将配置的信息转换成数值 try{ if(strWidth!=null&&strWidth.length()!=0){ width=Integer.parseInt(strWidth); } if(strHeight!=null&&strHeight.length()!=0){ height=Integer.parseInt(strHeight); } if(strCodeCount!=null&&strCodeCount.length()!=0){ codeCount=Integer.parseInt(strCodeCount); } }catch(NumberFormatExceptione){ e.printStackTrace(); } xx=width/(codeCount+1); fontHeight=height-2; codeY=height-4; } /** *@paramreq *@paramresp *@throwsServletException *@throwsjava.io.IOException */ protectedvoidser