I recieved a question about CAPTCHA integration in Struts2 based on AppFuse
integration at my personal email and thought I should post the response
here, since this is where all the appfuzers hang out and the answers may
help others. --Jason

==========================

Hi Daniel,
I'm glad to have a go at helping you, but just keep in mind that either the
Octo.com or Appfuse.org support channels may be more informative.  The
AppFuse framework can be based on Struts2, and that's what my example code
on appfuse.org uses.  You don't need the full-blown AppFuse meta-framework
to make it run.

In fact, the nice thing about AppFuse is that you can pick and choose what
frameworks you do want to use, and it's an excellent example of how to
integrate them.... So, though you've got an "imposed framework
architecture", you can still use AppFuse to get this code running and then
transfer it over to your model, using AppFuse as an example.

Other answers are inline below.

regards,
Jason


On Tue, Mar 18, 2008 at 8:07 AM, Daniel Varrin <[EMAIL PROTECTED]>
wrote:
> Hi Jason,
>  
> I saw on http://appfuse.org that you could implement a captcha using
> appfuse
> in a struts 2 project. I cannot use appfuse as I have an imposed framework
> architecture to use in my project, but it is based on struts 2 and I want
> to
> add a captcha validation.

"imposed frameworks" are pretty common, don't let it get you down :)

>  
> Do you know how can I load a BufferedImage from a   tag?

Yes, you can do this with a servlet like so:
captcha.jpg " name="captcha" />
Note: the servlet is literally mapped in the web.xml as "captcha.jpg". 
There is no image on the filesystem called captcha.jpg - it's the servlet
that is rendering this image because of the servlet mapping:
    <servlet-mapping>
        <servlet-name>captcha</servlet-name>
        <url-pattern>/captcha.jpg</url-pattern>
    </servlet-mapping>

>  
> I was following the procedure explained here:
> http://forge.octo.com/jcaptcha/confluence/display/general/5+minutes+application+integration+tutorial,
> but I was not able to make it work.

Hum, I haven't followed that documentation.  Maybe you could try this:
http://appfuse.org/display/APF/CAPTCHA+Integration

>  
> I have an ear, jar, war architecture and I've created the
> ImageCaptchaService and the servlet in the war part of my project. Is that
> right? It seems to be calling a spring factory too, but I don't understand
> why, although the project is using Spring.
>  

The com.octo.captcha.service.image.ImageCaptchaService is loaded in the
org/appfuse/webapp/servlet/ImageCaptchaServlet.java
 to create captcha images.  If you aren't using Spring, you'll have to
create a servlet init() method that will configure the ImageCaptchaService
properly as a member variable of the ImageCaptchaServlet.  Basically, you
need to use all of the class files in the Spring example for the AppFuse
CAPTCHA service, but code them in Java instead of XML.

> Is it possible to call an action that will return the picture and use this
> result in the "src" attribute of the   tag?
>  

Yes, you can do this using Struts (v1 or v2).  It would do the same thing
that ImageCaptchaServlet does though.  Basically all you get is the ability
to move the configuration of captcha image rendering from the web.xml into
the struts.xml.  This would be a good idea if everything you were doing was
within Struts.

> I hope you will be able to help me.
>  

I hope it helped. :)

>  
> Best regards,
> Daniel Varrin
> [EMAIL PROTECTED]
-- 
View this message in context: 
http://www.nabble.com/Re%3A-Captcha-in-Struts2%2C-and-AppFuse-tp16125363s2369p16125363.html
Sent from the AppFuse - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to