By javadujour
via jroller.com
Published: Feb 08 2007 / 06:27
Simple, nice looking captcha implemented in 100 lines of JSP. Easily change font, colors, size, and captcha characters.
By javadujour
via jroller.com
Published: Feb 08 2007 / 06:27
Comments
andrewnewdigate complained ago:
andrewnewdigate reported this link as lame on 02/08/2007 @ 11:12:21
Arrg! Scriptlets are nasty! This example is a blatant abuse of JSP. If Java Web developers have learnt anything in the last 7 years, it's avoid this sort of code! Keep your Java in a servlet/action/controller and avoid Scriptlets!
willcode4beer replied ago:
Agreed. This should be a servlet. JSP is a template language, if its going to be all java, then its better to use something else. Worse, its effectively one method. Even if it was a servlet, this should be refactored.
yumariso replied ago:
Oh, come on... A JSP is such an easy way to give some code a test run
willcode4beer replied ago:
It stops being easy after after 10 lines of code. A simple java class that produces an image is quicker, easier, easier to test, debug, and can get first clas support in a dev environment.
Calling the class from a servlet then requires about 2 lines of code.
Beyond having the code in a JSP is the mixing of concerns. Image generation and maintaining session data. These are two very different things. All-in-one, means you are left with one-off code. Breaking them up, means you could swap out captcha image generators simply, it also means the image generator could be used in other places.
Takse a little read over here:
http://blog.objectmentor.com/articles/2006/12/21/size-matters
egze complained ago:
egze reported this link as lame on 02/10/2007 @ 05:28:43
Voters For This Link (11)
Voters Against This Link (0)