<% @pageImport= "Java.awt.Graphics2D"%><% @pageImport= "Java.util.Random"%><% @pageImport= "Java.awt.Font"%><% @pageImport= "Javax.imageio.ImageIO"%><% @pageImport= "Java.awt.Color"%><% @pageImport= "Java.awt.Graphics"%><%@ pageImport= "Java.awt.image.BufferedImage"%><%@ page language= "java" pageencoding= "Utf-8" contenttype= "Image/png"%> <%intH = 45;intLen = 4;intW = len*20; Random R=NewRandom (); BufferedImage img=NewBufferedImage (W,H,BUFFEREDIMAGE.TYPE_INT_RGB); Graphics2D g=(graphics2d) img.getgraphics ();//G.setcolor (color.red);Color C =NewColor (245,245,245); G.setcolor (c); G.fillrect (0,0, w,h); String Str= "abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXY3456789"; G.setcolor (color.white); for(inti=0;i<20;i++) {G.setfont (NewFont ("Arial", Font.bold,r.nextint (20) +10)); C=NewColor (R.nextint (255), R.nextint (255), R.nextint (255), R.nextint (50)); String s=string.valueof (Str.charat (R.nextint (Str.length ())); G.setcolor (c); g.DrawString (S, R.nextint (W), R.nextint (h));} StringBuffer SS=NewStringBuffer (); for(inti=0;i<len;i++){ intn =-5 +r.nextint (10); G.rotate (n* math.pi/180); G.setfont (NewFont ("Arial", Font.bold,r.nextint (15) +15)); C=NewColor (R.nextint (255), R.nextint (255), R.nextint (255), R.nextint (55) +200); String s=string.valueof (Str.charat (R.nextint (Str.length ())); Ss.append (s); G.setcolor (c); g.DrawString (s),2+i*20,r.nextint (10) +25);} Session.setattribute ("Checkcode", ss.tostring ());//add interference line points for(inti=0;i<10;i++) {C=NewColor (R.nextint (255), R.nextint (255), R.nextint (255), R.nextint (80)); G.setcolor (c); G.drawline (R.nextint (w), R.nextint (h), R.nextint (W), R.nextint (h)); intSize = R.nextint (6) +5; G.filloval (R.nextint (w), R.nextint (h), size,size);} C=NewColor (R.nextint (255), R.nextint (255), R.nextint (255), R.nextint (150));intHH =r.nextint (h); for(inti=0;i<=300;i++) {G.setcolor (c); Doublex =i; Doubley = Hh+15*math.sin (10*i*math.pi/360); G.filloval ((int) x, (int) Y, 5,5);} G.dispose (); Imageio.write (IMG,"PNG", Response.getoutputstream ()); Out.clear (); Out=pagecontext.pushbody ();%>
JSP Verification Code