Question about the servlet Verification Code under LINUXG

Source: Internet
Author: User
Tags apache tomcat
For more information about the servlet Verification Code under LINUXG-Linux Enterprise Application-Linux server application, see the following. Our project uses struts1.2. I used sertlet to write a program to generate verification,

BufferedImage buffImg = new BufferedImage (width, height, BufferedImage. TYPE_INT_RGB );
Graphics2D g = buffImg. createGraphics ();

G. setColor (Color. WHITE );
G. fillRect (0, 0, width, height );

Font font = new Font ("Times New Roman", Font. PLAIN, 18 );
G. setFont (font );
G. setColor (Color. BLACK );
G. drawRect (0, 0, width-1, height-1 );

G. setColor (Color. GRAY );

Random random = new Random ();

For (int I = 0; I <40; I ++ ){
Int x1 = random. nextInt (width );
Int y1 = random. nextInt (height );

Int x2 = random. nextInt (10 );
Int y2 = random. nextInt (10 );

G. drawLine (x1, y1, x1 + x2, y1 + y2 );

StringBuffer randomCode = new StringBuffer ();

For (int I = 0; I <4; I ++ ){
String strRand = String. valueOf (random. nextInt (10 ));
G. setColor (Color. RED );
G. drawString (strRand, 13 * I + 6, 16 );
RandomCode. append (strRand );

// Put the verification code in the cookie
CookieHelper. setCookie (response, "random", randomCode. toString ());

ServletOutputStream out = response. getOutputStream ();
Required imageencoder encoder = required codec. createJPEGEncoder (out );
Encoder. encode (buffImg );
Out. close ();

If the code runs in linux for one or two days, the Verification Code cannot be displayed. the following error is reported:

Type Exception report


Description The server encountered an internal error () that prevented it from fulfilling this request.


Javax. servlet. ServletException: Servlet execution threw an exception
Org. jboss. web. tomcat. filters. ReplyHeaderFilter. doFilter (ReplyHeaderFilter. java: 81)

Root cause

Java. lang. NoClassDefFoundError
Java. lang. Class. forName0 (Native Method)
Java. lang. Class. forName (Class. java: 164)
Java. awt. GraphicsEnvironment. getLocalGraphicsEnvironment (GraphicsEnvironment. java: 68)
Java. awt. image. BufferedImage. createGraphics (BufferedImage. java: 1141)
Com. suntoward. scihoo. web. servlet. ValidateCode. doGet (ValidateCode. java: 38)
Javax. servlet. http. HttpServlet. service (HttpServlet. java: 697)
Javax. servlet. http. HttpServlet. service (HttpServlet. java: 810)
Org. jboss. web. tomcat. filters. ReplyHeaderFilter. doFilter (ReplyHeaderFilter. java: 81)

Note The full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.


Apache Tomcat/5.5.9

I still don't know why this problem occurs after several methods are changed. Thank you!
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.