This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JSP and the fly likes Registration page with 'Image Security Code' Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Registration page with Watch "Registration page with New topic
Author

Registration page with 'Image Security Code'

Gregor Samsa
Greenhorn

Joined: Jun 05, 2005
Posts: 7
Hi everyone..I need to find a way to build a registration page with 'Image Security Code' with JSP..I will display some random numbers/characters in an Image and the user will have to enter that code in order to register.(like yahoo does) I just wanna prevent automated registrations by doing this..I looked everywhere to find a source/article/code for this in JSP but I couldn't..Does anyone know how to do it ?
Thanks..
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
You are going to have to display an image either selected from a set of static image files on the server or create one on the fly using the Java graphics capabilities.
If you go dynamic, note that your JSP is just going to write an <img tag which has a src pointing to a servlet that will generate the image. You can use a session variable to contain the code.
I suggest you get the JSP registration page generation working with a static image first.
The topic of serving images has been discussed frequently around here, generally in the context of graphics generated from database results but the principle is the same.
Bill
Gregor Samsa
Greenhorn

Joined: Jun 05, 2005
Posts: 7
Originally posted by William Brogden:
You are going to have to display an image either selected from a set of static image files on the server Bill


I think I'm gonna go with this option thanks Bill..What about the speed ? Does it make any difference from one to another ? (on the fly & static) Which one is faster you think ?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61103
    
  66

This functionality is known as a "captcha". More info here.

Also google for "java captcha" for lots of links.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
What about the speed ?

Sigh - another person worrying about speed at the wrong point.
Considering all of the time consuming operations involved in a servlet, the difference between serving a static image file and building one on the fly would be very hard to measure. "Premature optimization is the root of all evil." Get the code correct and clear first.
Bill
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61103
    
  66

"Premature optimization is the root of all evil." Get the code correct and clear first.


A needle-point sampler saying this should be mandatory on all office/cubicle walls.
Gregor Samsa
Greenhorn

Joined: Jun 05, 2005
Posts: 7
thanks bear && bill 'captcha' was what I was looking for I will try to implement it. If you find any othe tutorials / sources on this please let me know..: )
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61103
    
  66

google
kees ... voogd
Greenhorn

Joined: Jun 27, 2005
Posts: 1
you can download a simple one here:
http://145.99.209.105/captcha/SimpleCapchaExample.jsp

kj
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61103
    
  66

"kees ... voogd",

There aren't may rules that have been put into place here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender
Gregor Samsa
Greenhorn

Joined: Jun 05, 2005
Posts: 7
Originally posted by kees ... voogd:
you can download a simple one here:
http://145.99.209.105/captcha/SimpleCapchaExample.jsp

kj


thanks kj : ) bu the link is broken
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Registration page with 'Image Security Code'