File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes JCaptcha and Struts problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "JCaptcha and Struts problem" Watch "JCaptcha and Struts problem" New topic

JCaptcha and Struts problem

Em Aiy
Ranch Hand

Joined: May 11, 2006
Posts: 226

I am using JCaptcha for captcha features. It is working fine. I have this code in CaptchaServlet and this code save the captcha in request

Now, i get this captcha in form Action from req and validate it etc.

In that form i set the following header for the JSP page

So that my captcha does not remain in cache. Now there is one issue. If i keep the page open for 10-15 minutes and after that i submit it, the actionform does not find any captcha (ok fine - make sense). The page is re-displayed but it display with the LAST CAPTCHA (it does not generate the new one) or at least generate the new one but does not show it.

So what coould be possible modification should i made so that my PAGE GURANTEE to show the new CAPTCHA IMAGE each time it loads (F5 or CTRL + F5).

The difference between <b>failure</b> and <b>success</b> is often being <b>right</b> and being <b>exactly right</b>.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33124

Is using POST an option? That would force a trip to the server where you could create a new captcha.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Em Aiy
Ranch Hand

Joined: May 11, 2006
Posts: 226
I am using this code in CaptchaServlet POST method

Here is the code i have writen in action form, which validate the captcha

Now, when the exception occurs, it sends back to the url with "ERROR" message and it does not update the captcha (most of the time).
I agree. Here's the link:
subject: JCaptcha and Struts problem
It's not a secret anymore!