File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Please help me with CAPTCHA

 
chaitanya karthikk
Ranch Hand
Posts: 806
Java MySQL Database Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody, I am Chaitanya, I am working on captcha, I have a web page where the user has to enter the captcha text. For this I am using servlets.

The procedure what I am following is:

1> A servlet will receive the request.
2> Then it creates an attribute called "passed".
3> Then using nextInt(int) method of Random class, I will generate a random integer between 0 and 100
4> There is a folder named captchaimages where all the images(jpeg) are saved.
5> The names of the images are between 0 to 100.
6> There is a mapping file, which image represents which text.
7> So depending on the random number I get, I send the number to a view.
8> The view then requests for the image.
9> After the user submits the form, with AJAX I am sending the captcha text to a servlet.
10> The Ajax code will send the image number and the text which the user entered.
11> From the mapping file I'll check whether this number maps this text or not.
12> If yes the form will be submitted or else another random number will be generated which is not equivalent to this one and the ajax response is sent back.

This is what I have in my brain, please anyone tell me whether I am going in a right way or not.

Thank you all in advance. Have a good day.
 
Gian Franco
blacksmith
Ranch Hand
Posts: 979
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chaitanya,

This will probably be relatively more difficult to maintain than
other solutions where the image is generated randomly.

Did you have a look at some existing (free) solutions?
 
Gian Franco
blacksmith
Ranch Hand
Posts: 979
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An open source java framework I used in a
previous project is JCaptcha it works very well.
 
chaitanya karthikk
Ranch Hand
Posts: 806
Java MySQL Database Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mr. Gian, I googled about captcha, everywhere I go, I got details about captcha, nobody said how to implement captcha. I searched in jsp and servlets forum also. I did not get any clear information about how to do it.

Can you tell me how to do that. Is my solution a worst one?
 
chaitanya karthikk
Ranch Hand
Posts: 806
Java MySQL Database Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mr. Gian, I searched JCaptcha examples, they were easy to understand. but one thing I did not understand is, from where the images are generated. They are not using any image folder or path of the captcha images. How the images are generated?
 
Gian Franco
blacksmith
Ranch Hand
Posts: 979
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chaitanya,

...you can drop the Mr.

Your solution is fine and a good learning experience when implemented, tested
and hardened to be up to the job for what captcha is meant to be: a security solution.

In a nutshell JCaptcha, has distinct parts (i.e. java classes) with different
responsibilities for things like font generation, background generation, etc.

E.g. you can tell JCaptcha how you want your image to look like when it
comes to font, its color and the background colors as well.

hth
 
chaitanya karthikk
Ranch Hand
Posts: 806
Java MySQL Database Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Gian. I will go with JCaptcha.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic