Link to home
Start Free TrialLog in
Avatar of jabcoco
jabcocoFlag for Canada

asked on

Images random creator and validator (with number and caracters) (Like hotmail)

Hi..
I'm looking for something in jsp and java, that create a image ( with caracters and number), like hotmail does.

I want to create a inscription form, and at the end the new user have to reenter what he see on the create image to be able to precess the request.
This will ensure that a user calling my service and not a automatic system from someone else..

Anybody can help me..
Thanks
Avatar of bloodredsun
bloodredsun
Flag of Australia image

Sounds like a good idea

Here's an article showing you how to create images for servlets (and it's equally applicable for JSPs): http://www.javaworld.com/javaworld/jw-05-2000/jw-0505-servlets.html
Avatar of jabcoco

ASKER

I've already read this page, but that simply explain how to genera a simple image, that not explain how to generate an image code (Image with a code text) that the user has to type in an input text. And that not explain how can i valid if the image code fit with what the user entered in the text field....

Any other idea..
Any library or util to use as a black box to generate the image? then valif if image match with the enteres text field.....

Thanks
ASKER CERTIFIED SOLUTION
Avatar of bloodredsun
bloodredsun
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jabcoco

ASKER

Great thanks bloodredsun..
Basic idea is there... thats what i need. now i'm gonna try to fine tuning a little bit this for more securiting image with line and things like thanks......

Big thanks!
Avatar of jabcoco

ASKER

But..... can i change the font style of the caractere i print.. or the color of each lettre i print... and create a kind of more hard to read image... to get a bettre security image...
???
>>can i change the font style of the caractere i print.. or the color of each lettre i print... and create a kind of more hard to read image... to get a bettre security image...

Yes. Draw each letter as an individual String and use these two methods to change the color and font

            g2d.setColor(Color color);
            g2d.setFont(Font font) ;

You'll have to reset the location of each string you write as they are all written in relationto  the same starting location. ALthough it might be a good idea to over-lap them slightly as auto-recognition is very tough then

>>Big thanks!
No probs dude! Just remember me when it comes to point and grades :-)
FYI: here's a class that will print out your avialable fonts:
-------------
public class GetAvailableFonts {
            
      public static void main (String[] args){
      
            // Get all font family names
            GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
            String fontNames[] = ge.getAvailableFontFamilyNames();
            
            // Iterate the font family names
            for (int i=0; i<fontNames.length; i++) {
                  System.out.println(fontNames[i]) ;
            }
      }
}
Avatar of jabcoco

ASKER

Nice.. real thanks.. then if i want to generate "tricky line" like hotmail.. is it possible the Graphics2D?!?!

Thanks..
Any thing is possible in G2D. It's just not the most intuative graphics format....:-(

And what do you mean by "tricky line" exactly (I've never used hotmail)
Avatar of jabcoco

ASKER

Heu.. something like Yahoo resgitration or something like any other site where you need to add in a text box what caracters you see in the image, to valid your registration...
Though so, but I wanted to make sure.
Avatar of jabcoco

ASKER

thanks for the time you pass bloodredsun!!!!
cheers