You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by alee amin <ma...@gmail.com> on 2007/10/03 14:03:57 UTC

JCaptcha + Struts problem

Hi,

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


    public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {

        ImageCaptcha pixCaptcha = factory.getImageCaptcha();
        BufferedImage bi = pixCaptcha.getImageChallenge();
        resp.setContentType("image/jpg");
        JPEGImageEncoder jpegEncoder = JPEGCodec.createJPEGEncoder(
resp.getOutputStream());

        jpegEncoder.encode(bi);
        resp.flushBuffer();

        req.getSession().setAttribute("pixCaptcha", pixCaptcha);
    }


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


response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
response.setDateHeader ("Expires", 0); //pr


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).

-alee
-- 
Muhammad Ali
http://techboard.wordpress.com
Software Engineer - E2ESP
muhammadaliamin(at)gmail(dot)com