Solve the Problem of invalid JSP Verification Code refresh

Source: Internet
Author: User

In the form

[Html]
<Form name = "infof">
<Font color = "red"> name: </font> <input name = "name" type = "text"> </input> <br>
<Font color = "red"> password: </font> <input name = "password" type = "password"> </input> <br>
Verification Code: <input name = "validate" type = "text">

<A href = "JavaScript: refresh ()"> you cannot see it clearly. Change it to another one. </a>
<Br>
<Input type = "button" onclick = "login ()" value = "login"> <input
Type = "reset">
</Form>

In the verification code image, validate. jsp is called to generate the verification code image. The content in this jsp is as follows:

[Html]
<Body>
<%
Response. setHeader ("Pragma", "No-cache ");
Response. setHeader ("Cache-Control", "no-cache ");
Response. setDateHeader ("Expires", 0 );
BufferedImage image = new BufferedImage (75, 30,
BufferedImage. TYPE_INT_RGB );
Graphics g = image. getGraphics ();
G. setColor (Color. gray );
G. fillRect (0, 0, 75, 30 );
 
String randStr = String. valueOf (new Random (). nextInt (8999) + 1000 );
Session. setAttribute ("randStr", randStr );
 
G. setColor (Color. black );
G. setFont (new Font ("", Font. PLAIN, 20 ));
G. drawString (randStr, 10, 20 );
For (int I = 1; I <= 120; I ++ ){
Int x = new Random (). nextInt (75 );
Int y = new Random (). nextInt (30 );
G. setColor (Color. blue );
G. drawOval (x, y, 1, 1 );
}
ImageIO. write (image, "JPEG", response. getOutputStream ());
Out. clear ();
Out = pageContext. pushBody ();

%>
</Body>
Okay, now we have a big show.

In


<A href = "JavaScript: refresh ()"> you cannot see it clearly. Change it to another one. </a>

Both the link and onclick methods refer to a method in js.

The details are as follows:

[Javascript]
<Script type = "text/javascript">
Function refresh (){
Infof. vali. src = "";
Infof. vali. src = "validate. jsp ";

}
</Script>

Originally, infof. vali. src = ""; I don't have this statement. When I click images or links, I find that validate. jsp is not called. No matter how I set the cache settings (maybe I have not set it to the point)

I tried to solve the problem of invalid Verification Code refresh.

After testing, you can link and click images ~~~ Problem Solving


From MELEARNER's column

Related Article

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: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.