JCaptcha - refresh image

Hi,
I'm trying to build a registration page with captcha image, and enables user to change the captcha image by clicking a link.
I tried the open-source JCaptcha project. (5 minutes application integration tutorial http://luminal.gotdns.com/confluence/display/general/5+minutes+application+integration+tutorial)
It worked fine when first load the page. But when I click reload, exception happends:
If I try to reload after ,say 5 mins, the page works again.
java.lang.ClassCastException: java.lang.String
     net.sf.ehcache.Element.equals(Element.java:165)
     java.util.HashMap.eq(Unknown Source)
     java.util.HashMap.removeEntryForKey(Unknown Source)
     java.util.HashMap.remove(Unknown Source)
     net.sf.ehcache.store.MemoryStore.remove(MemoryStore.java:219)
     net.sf.ehcache.Cache.remove(Cache.java:716)
     net.sf.ehcache.Cache.remove(Cache.java:683)
     com.octo.captcha.service.EhcacheManageableCaptchaService.generateAndStoreCaptcha(EhcacheManageableCaptchaService.java:826)
     com.octo.captcha.service.AbstractCaptchaService.getChallengeForID(AbstractCaptchaService.java:538)
     com.octo.captcha.service.image.EhcacheManageableImageCaptchaService.getImageChallengeForID(EhcacheManageableImageCaptchaService.java:505)
     ImageCaptchaServlet.doGet(ImageCaptchaServlet.java:36)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
I read the example code, found that it takes session id as key to recognize the request. So, it seems to be: when reload attempts, the same session id is sent to the service to acquire an image, but the captcha service doesn't support one session id with different images.
Can anybody guide me to make it work? any other resource can help to solve the problem?

I use current time (System.currentTimeMillis()) instead of session id as a key for captcha image generation, and a new captcha image is generated everytime I relaod the page. :)
However, I don't know how to pass current time from servlet to the request page, so that the request page can laterly send the key back to servlet for captcha validation.
My jsp pages is like:
<form name="LoginPage" action="/jcaptcha/ImageCaptchaServlet" method="get">
<img src="jcaptcha">
<input type='text' name='j_captcha_response' value=''>ImageCaptchaServlet ( copied from http://luminal.gotdns.com/confluence/display/general/5+minutes+application+integration+tutorial)
        //the same id must be used to validate the response, the session id is a good candidate!
//        String captchaId = httpServletRequest.getSession().getId();
          String captchaId = Long.toString(System.currentTimeMillis());     
        // call the ImageCaptchaService getChallenge method
            BufferedImage challenge =                     CaptchaServiceSingleton.getInstance().getImageChallengeForID(captchaId,httpServletRequest.getLocale());
        captchaChallengeAsJpeg = jpegOutputStream.toByteArray();
        // flush it in the response
        httpServletResponse.setHeader("Cache-Control", "no-store");
        httpServletResponse.setHeader("Pragma", "no-cache");
        httpServletResponse.setDateHeader("Expires", 0);
        httpServletResponse.setContentType("image/jpeg");
        ServletOutputStream responseOutputStream =
                httpServletResponse.getOutputStream();
       responseOutputStream.write(captchaChallengeAsJpeg);
       responseOutputStream.flush();
        responseOutputStream.close();

Similar Messages

  • Refreshing Images on Reload or Refresh

    Looking for code to refresh images on refresh, or ever 5 seconds, anyone help me out? Totally new to this.
    [email protected]

    More information required.
    So far all I could recoment is [url http://java.sun.com/j2se/1.5.0/docs/api/java/util/Timer.html]java.util.Timer

  • Refreshing Image Preview in Finder

    Is there a way to get the Finder to refresh the image preview in coverflow, or list view? I pulled in a bunch of photos from a DVD and have them in the Finder, but there is no image preview and/or icon that gives you the little thumbnail. If I hit spacebar, I can see the image just fine, but I want to quickly select images from the Finder without having to pull them into Lightroom or something. They are all JPEGs that I'm looking at. Thanks.

    Click anywhere on your desktop. Then, go to Finder > View > View options and check "show item info" and "show icon preview". That should provide what you want.

  • Refresh image in a ScrollingImagePanel. Please help me!

    Hello friends. I am new at the "Java World". At first, sorry for my bad English. Lets go:
    In my aplication I have to show a tiff image in a ScrollingImagePanel.I aplly some efects on the image, for example rotate the image, etc.
    It is working fine, but I have problem to refresh the image in the same ScrollingImagePanel.The code compiles but I have exceptions when I run the method:
    public void atualiza(){
    if (ziboro == false){ //no images displayed yet.
         ziboro = true;     
         JInternalFrame test = new JInternalFrame("Test",true,true,true,true);
    test.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    test.addInternalFrameListener(this);
    test.setLocation(10,10);
    test.setSize(new Dimension(200,200));
    ScrollingImagePanel FlipVPanel = new ScrollingImagePanel(imagemBufa, 800, 800);
    test.getContentPane().add(FlipVPanel);
    displayPanel.add(test);
    test.setVisible(true);
    test.moveToFront();
    return; }
    //This part is my problem.
    teste.getContentPane().remove(FlipVPanel);//it causes exception
    ScrollingImagePanel FlipVPanel = new ScrollingImagePanel(imagemBufa, 800, 800);
    teste.getContentPane().add(FlipVPanel);
    teste.setVisible(true);
    teste.moveToFront();
    I think tyhe problem is when I try to remove the ScrollingImagePanel, because when I add a ScrollingImagePanel and I remove imediatly after , the ScrollingImagePanel disapear.
    Please help me, you are my hope.
    Thanks a lot, lot, lot, ....!

    I can't either with my Treo700wx, and from what I see with my plan, it's definitely because of Alltel.  They have a seperately priced option for picture messaging that I had with my old (non-smart) phone that isn't even an option with the smart-choice packages.
    So...I'm also listening.  Having the only way to send pictures with the phone being through email is pretty dumb.  We pay enough for the plans, you'd think they could include it...or at least offer it as an option.
    Post relates to: Treo 700wx (Alltel)

  • Refreshing Image files in Dreamweaver

    I have changed a few image files that show up in all of my
    many individual web page files. I saved the new files in the same
    place and with the same name as the old files, but the old files
    still show up in my Dreamweaver files. The main difference between
    the new files and the old ones are that the new ones are bigger in
    dimension. The refresh button in my toolbar remains unusuable. It's
    gonna take forever to re-place all the images in each web file. Can
    someone please help?
    -Crystal
    Here is an example of old file verses new file:
    (NEW)
    <img src="../../images/Easter/page_59.jpg" width="34"
    height="32" />
    (OLD)
    <img src="../../images/Easter/page_59.jpg" width="27"
    height="35" />

    Did you recreate the site cache? (Site/Advanced/Recreate Site
    Cache)
    Nancy Gill
    Adobe Community Expert
    BLOG:
    http://www.dmxwishes.com/blog.asp
    Author: Dreamweaver 8 e-book for the DMX Zone
    Co-Author: Dreamweaver MX: Instant Troubleshooter (August,
    2003)
    Technical Editor: DMX 2004: The Complete Reference, DMX 2004:
    A Beginner's
    Guide, Mastering Macromedia Contribute
    Technical Reviewer: Dynamic Dreamweaver MX/DMX: Advanced PHP
    Web Development
    "Jackeltree" <[email protected]> wrote in
    message
    news:e407dt$7af$[email protected]..
    >I have changed a few image files that show up in all of
    my many individual
    >web
    > page files. I saved the new files in the same place and
    with the same
    > name as
    > the old files, but the old files still show up in my
    Dreamweaver files.
    > The
    > main difference between the new files and the old ones
    are that the new
    > ones
    > are bigger in dimension. The refresh button in my
    toolbar remains
    > unusuable.
    > It's gonna take forever to re-place all the images in
    each web file. Can
    > someone please help?
    >
    > -Crystal
    >
    > Here is an example of old file verses new file:
    > (NEW)
    > <img src="../../images/Easter/page_59.jpg" width="34"
    height="32" />
    > (OLD)
    > <img src="../../images/Easter/page_59.jpg" width="27"
    height="35"
    > />
    >

  • Refreshing image ( and not displaying the one in the cache )

    Hello , I made an app with many galleries stored locally but i made another section with a daily image, and this image is located on an ftp server http://XXXXX.com/image.png for example so everyday i upload the new one with the SAME name as the older one
    ( that is replaced by the newest ) , however the app is always displaying the older one , even if i restart the app , the computer or kill completely the app.
    How could i do please?
    Could i add something next to the image url (in a gallery module) to make it refresh everytime the app loads?
    PS : if you couldn't solve this problem could i put a button to refresh the image?
    Thanks
    EDIT : I reinstalled my app and changed several times the image and now it's working?
    Is it temporarily so this image will be cached and the issue will appear once more or was it a bug?

    Hello
    I don't believe you can without addressing/changing the way the image is loaded on your server.
    You have several options to remove the caching even from files you upload.
    You can for example use a .htaccess file in the folder where your image is uploaded
    (assuming your webserver is an apache server)
    <IfModule mod_expires.c>
    # Enable expirations
    ExpiresActive On
    # Default directive
    ExpiresDefault "access plus 1 day"
    # Images
    ExpiresByType image/gif "access plus 1 minute"
    ExpiresByType image/png "access plus 1 minute"
    ExpiresByType image/jpg "access plus 1 minute"
    ExpiresByType image/jpeg "access plus 1 minute"
    </IfModule>
    You can also set the header using a loading script in php, asp or whatever language your server supports (e.g. showimage.php?img=blabla.png which allows you to set the no cache header (or limited cache header) in the php header before loading it in your
    applications (works also for asp, etc.). Any searchengine will give you some inspirational examples.
    Regards
    StonyArc

  • Refreshing image in jsp

    I use cewolf which renders a chart using data from a DataProducer. Now, these datas changes frequently, and what I want is to have a chart where those changes are shown "live", meaning I need to refresh the image every so often.
    I need that just the image is refreshed. Nothing else... anyone here who can help?

    I think this can be done with thread which should be executed every certain interval.
    Also you should put image display logic in servlet
    You can create an Iframe and call eth above servelet inside the Iframe. By using this only Iframe will get updated.
    ~Aman

  • How to refresh image component JSP?

    hi i am using Netbeans 6.01 and developing a web project.
    I need to do some manipulation on an image according to input and save the image at address in the project/build/resources/image with the same name when user press a button but sometimes page refreshes the image and sometimes it does not refresh.I don't know what to do
    thank you for your interesting and help if u need more details about the problem please just ask me.

    I have just discovered something this is not about the code that i wrote
    double x=0;
    while(x<=1000000000)
    x++;
    super.init();
    init();
    i delete this code when i reload page once after that all of my requests works properly.I mean when i press reload button of the browser once then page works and image is resfreshes.
    Now i can solve the issue if anybody can tell me how to reload a page when i press a button
    i don't wanna use the javascript onclick() window.location.reload().
    Edited by: maniacneron on Dec 24, 2008 2:34 PM

  • How to refresh images placed with XML?

    Hi folks!
    I placed some images and texts with XML to an InDesign (CS5) document. Unfortunately it's possible that the file is modified. In that case I want to start a script which updates the links. But that should happen later. First it's necessary to check if updating is possible.
    For that I modified the file and refreshed my linked file. But all that is replaced are my texts. The images vanished and I had to place them again by hand.
    What am I doing wrong? Could anybody help please?
    With kind regards,
    Steffi

    Ok, maybe somebody knows the problem when I'm posting some images. I made a screenshot of my InDesign XML and after you can see my XML-File.
    And here's my XML-File:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <Lage>
        <wohnlage>Gute Wohnlage im Grenzbereich zu sehr guter Wohnlage</wohnlage>
        <Lagebeschreibung>Der Mornroe-Park liegt in einer guten Wohnlage. Die blauen Punktelinien zeigen die Grenzen der PLZ-Bereiche.Der Monroe Park liegt im Grenzbereich zwischen PLZ 14167 und 12205.</Lagebeschreibung>
        <Legende href="H:\05_1Produkte\2010\005_Riskanalyser2010\Karten\Lagelegende.png"/>
        <Lagekarte href="H:\05_1Produkte\2010\005_Riskanalyser2010\Karten\20012_Karte.jpg"/>
        <Kartenuntertitel>diese Karte beinhaltet blablabla</Kartenuntertitel>
    </Lage>

  • Refresh Image when viewing reporrt

    Post Author: PARK BM
    CA Forum: .NET
    Sorry, I can't english little....
    Report contain chart image file.
    That image file is saved in the HDD's folder.
    Chart image file is changed often.
    But image is not change, exeption first runtime
    How did you solve this problem?
    environment is VS.NET 2005 and CrystalReports.Net

    >
    I have an applet which shows an image on the server and refreshes it with a defined time interval.
    When I open the applet with appletviewer, the program works without any errors.
    But, when I open applet in a web browser (IE , Firefox), applet always shows the first image. It doesn't update.>Java in browsers is notorious for image caching. One way around it is to read the byte[] of the image directly from the input stream of the image URL, then use [Toolkit.createImage(byte[])|http://java.sun.com/javase/6/docs/api/java/awt/Toolkit.html#createImage(byte[])] to stamp out an Image instance.
    >
    PS: I test the applet on my computer, I change the image with Paint .)
    I am not sure about suspend, resume, stop,etc methods of Thread. I wrote them in this way, because using them
    as "myThread.suspend()" is depreciated. >I suspect it would be better to have the applet maintain a Runnable object as an attribute, rather than implement Runnable.

  • Captcha refresh image

    I've implemented SimpleCaptcha-1.1.1.jar in Fusion Web Application (ADF), (excellent tutorial on http://www.oracle.com/technology/products/jdev/tips/fnimphius/captcha/captcha.html). Only thing that's missing in tutorial is refreshing the captcha image without reloading the whole page.
    Does anyone have a hint on how to do this? I've tried with panelPartialRoot so far, but without success.
    Thanks,
    Jelena

    Hi,
    this actually is what I could not resolve. The PPR is successful but the image seems to be sticky - though its not configured as sticky image. I tried with PPR on different levels - including programatic refresh. No chance. It might be the captcha solution I used for the article, but I didn't yet try another captcha software to see if its the image or the implementation in ADF Faces
    Frank

  • Problem with refresh image on portlet

    I have a PAGE WITH A PORTLET THAT IS A REPORT OF A TABLE with a image.
    IF J CHANGE A RECORD WHEN I OPEN THE PAGE IS DISPLAYED THE OLD INFORMATION
    UNTIL I PRESS THE "F5" KEY ON THE BROWSER (THE REFRESH KEY OF THE BROWSER).
    I HAVE TRY TO PUT (DON'T CACHE FOR THE PAGE) BUT THE THING REMAIN STILL !
    DO YOU KnOw SOMETHING ?

    ok, I'll try to explain better.
    1) I have a table with a BLOB field to store images.
    2) When I save the image in the database it saves ok.
    3) Shows the image perfectly in a field "Display Image"
    4) When I delete the image and record another, the database is ok, but it seems that the image remains in the cache, I even writing a new image.
    5) Demonstrate the new image only when I logoff and login again.
    Regards,
    Márcio.

  • How to refresh image preview icons in Finder?

    I often browse through my photos directly in Finder. Many of my photos have been rotated from landscape to portrait format using Preview, but the preview icons I see in my Finder window remain in landscape format. How do I refresh the icons to make them reflect the new, modified image?
    Thanks.

    Hi Saigon Cinnamon, and a warm welcome to the forums!
    I'm not 100% positive, but I think the problem is that Preview & iPhoto only "tag" them as rotated & doesn't actually rotate them.
    I think Finder in 10.5 or 10.6 understand & respects that tag, but not in Tiger.
    I'd try really rotating one & re-saving it in say GraphicConverter...
    http://www.macupdate.com/info.php/id/263

  • JCaptcha security Image generation

    hi all,
    in this link :
    http://forge.octo.com/jcaptcha/confluence/display/general/5+minutes+application+integration+tutorial
    i followed all steps described in tutorial above & manage to get the servlet run well on my local tomcat server (localhost:8080).
    the problem is when i deployed the servlet to a remote server and run it ;the image didn't got displayed .this puzzled me !
    i tried many solutions like giving absolute url for img tag instead of relative urls. i also gave a jpg extension to img src tag instead of servlet path..but every time the servlet works on localhost & fail to display captcha image on remote server.
    what could be the problem ?
    any hints or ideas are very welcomed.
    thanks.

    Probably it would be a faster approach if you find some ready to use code. Not sure if you would get one ..
    But I would prefer not to sit idle & wait and instead re-invent the wheel.
    My approach ...
    Get many alphanumeric images [say a 100 images] created by a designer. Name the images the same way as it displayed ..i.e. it show RO17 then the file name would be RO17.jpeg
    Load an Array with the names of those 100 images [select the file names from a DB Table].
    Before page load get a random number from 1..100 and retreive the image name corresponding from your Array's element position. Store that image name in session/request and load the page with that image. Then compare with the inputted value on form submit and handle the success/failed operations.
    Hope you got the proposed concept.
    -Rohit
    Hope I did not leave any loop holes for hackers. ;-)
    Message was edited by:
    RohitKumar

  • Want to refresh Image Capture without disconnecting device

    I'm using Image Capture to import iPad Screen captures to my iMac.  The problem is that it "sees" only those images that were on the iPad when Image Capture started up. 
    In order to see subsequent images, I have to physically disconnect ("pull the plug") my iPad from my Mac.  After I reconnect, Image Capture mounts the iPad anew and the the new images are visible.
    Quiting Image Capture and relaunching it does not have the same effect, so it is obviously some OS function that is mounting/unmounting the iPad device.
    Is there any OSX command that will do what I want (I'm comfortable using Terminal).  I guess it would be something like mounting/ejecting a disk, but for a USB device instead.
    I'd welcome info on any alternative ways of getting those new images over to my Mac for processing.
    Thanks for any help.
    Frank

    I'm having the same problem with my iphone 4 and was sure that it was possible before updating to iOS 5. I've just checked this theory using my ipod touch which is still running iOS 4 and can confirm that it's something that used to be possible - new photos taken show up immediately in Image Capture as they are taken on the iPod. I'm wondering if this change has anything to do with iCloud.
    Bit annoying so I'll be very interested to see if you come up with a work around...

Maybe you are looking for

  • Illustrator not responding.. 'force quit' is futile too !

    Hi! My illustrator stopped working in the middle of my trying to save an illustrator file. I am awfully stuck as my mac is not shutting or restarting too.. says 'please quit illustrator to shut down/ restart'. I have no idea and although have been re

  • Battery iphone 5 new IOS

    I sold my 3 months old iphone 4s becouse unusual Battery drain:(  got a new iphone 4 and is same..lossing %50 without use infew hours!!! i search and everyone belive is new ios update causing this problem. app store asked me to make a FRESH restore a

  • Topic and content level conditional build tags

    What is the difference between a topic level and a content level conditional build tag? Why would you select one over the other? How do you select one over the other.

  • Oracle Business Intelligence (OBIEE) Keeps Kicking Me Out

    Im quite confused about what is going on with OBIEE. I have a DEV, QA and PROD enviroment. In both DEV and PROD I can log in to OBIEE, navigate around no problem. When I go into QA then everytime I click on a report link or navigate anywhere it const

  • Authorization for JAX-WS webservice

    Hi, I am using weblogic 10.3. For my JAX-WS web service I am using @Policy(uri = "policy:Wssp1.2-2007-Https-UsernameToken-Plain.xml") for security. This policy authenticate all the users of default realm. But I want to restrict access to the users wh