|
Blue Forest http://www.lslnet.com at 10:18 on June 6, 2006
Jsp authentication code are unable to operate normally, we look at how to help solve them?
Tomcat5.0.12 system is operated below the JSP pages of the certification procedure code has only to take a fork in the box, not a normal show photo below is a code to help look at how everyone else?
A.jsp
"%Page contentType=" text/html;charset=gb2312 "%>;
"Html>;
"Head>;
"Title>; Authentication Code page" /title>;
"/head>;
"Body>;
"Table>;
"Tr>;
"Td align=left>; authentication code :" /td>;
"Td>;<img border=0 defended" image.jsp "" ;</td>;
"/tr>;
"/table>;
"/body>;
"/html>;
Image.jsp
"%Page contentType=" image/jpeg "import=" java.awt.*.
Java.awt.image.*, java.util.*, javax.imageio.* "%>;
<%!
Color getRandColor (fc int, int bc) {// scope to be random colors
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);
}
%>;
<%
4003rd page is not set up buffer
Response.setHeader ( "Pragma", "No-cache");
Response.setHeader ( "Cache-Control", "no-cache");
Response.setDateHeader ( "Expires", 0);
4003rd created in the image memory
Int width=60, height=20;
BufferedImage image = new BufferedImage (width, height, BufferedImage.TYPE_INT_RGB);
4003rd access graphic context
Graphics g = image.getGraphics ();
4003rd randomly generated category
Random random = new Random ();
4003rd set the background color
G.setColor (getRandColor (200,250));
G.fillRect (0, 0, width, height);
4003rd font set
G.setFont (new Font ( "Times New Roman" Font.PLAIN,18));
4003rd painting framed
//g.setColor (New Color ());
//g.drawRect (0,0, width-1, height-1);
4003rd randomly generated 155 of interference lines, so the image authentication code is not easy to detect by other procedures
G.setColor (getRandColor (160,200));
For (int i=0;i<155;i++)
{
Int x = random.nextInt (width);
Int y = random.nextInt (height);
Random.nextInt x1 = int (12);
Random.nextInt Binkōylū = int (12);
G.drawLine (x, y, x+xl, y+yl);
}
4003rd take random authentication code (4 digits)
String sRand= "";
For (int i=0;i<4;i++) (
String rand=String.valueOf (random.nextInt (10));
SRand+=rand;
4003rd will show that image authentication code
G.setColor (new Color (20+random.nextInt (110), 20+random.nextInt (110), 20+random.nextInt (110)));
4003rd transfer function of the same color, because the seeds may be too close to it, I can only direct Generation
G.drawString (rand,13*i+6,16);
}
4003rd authentication codes will be deposited SESSION
Session.setAttribute ( "rand" sRand);
4003rd image effect
G.dispose ();
4003rd output images to the page
ImageIO.write (image, "JPEG" response.getOutputStream ());
%>; |
Jsp authentication code are unable to operate normally, we look at how to help solve them?
If the server is Linux, then try this.
-Djava.awt.headless=true Behind parameters : increase in java |
Jsp authentication code are unable to operate normally, we look at how to help solve them?
2000 : operating under tomcat was back upstairs, huh, huh, I would try out, the script is activated
Startup.bat script can be activated if the tomcat normal, but the service started using WIN2000 tomcat can not show |
| |