Link Details

Link 13041 thumbnail
User 190393 avatar

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.
  • 11
  • 0
  • 5078
  • 1789

Comments

Add your comment
User 197452 avatar

andrewnewdigate complained ago:

0 votes Vote down Vote up Reply

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!

User 209464 avatar

willcode4beer replied ago:

0 votes Vote down Vote up Reply

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.

User 95730 avatar

yumariso replied ago:

0 votes Vote down Vote up Reply

Oh, come on... A JSP is such an easy way to give some code a test run

User 209464 avatar

willcode4beer replied ago:

0 votes Vote down Vote up Reply

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

User 210924 avatar

egze complained ago:

0 votes Vote down Vote up Reply

egze reported this link as lame on 02/10/2007 @ 05:28:43

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Voters For This Link (11)



Voters Against This Link (0)