• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

captcha, using simple servlet and struts mapping

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a struts application which uses a captcha in one of its forms.
The captcha is generated by a simple servlet.
Currently i have a mapping in the web.xml for the servlet.

And in my form in i use "html:image" tag to display the captcha image.

So, here are my questions:
1) Can I map simple servlet like the one above directly in my struts-config xml file, instead of using web.xml?
I am considering this so that in an event of change, i need to change only the struts-config file.
Please treat this as general question and not just with respect to captcha service because I have to use 2 more servlets in my application.

2) I was curious if i can use global-forward for this captcha image. If so how to do it?
I tried using global-forward but was not successfull
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A forward isn't going to work in this situation because you're not forwarding, but including. An image is included as a part of a page, while a forward passes control on to another page.

If you want to have only the struts action servlet defined in your web.xml file, I'd suggest taking the same basic logic you put in your captcha servlet and creating a captcha action. You can then render the image through an <html:image> tag just as you're now doing with the servlet.
 
azhar bharat
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


If you want to have only the struts action servlet defined in your web.xml file, I'd suggest taking the same basic logic you put in your captcha servlet and creating a captcha action. You can then render the image through an <html:image> tag just as you're now doing with the servlet.



Then do I return null instead of forwardaction in the action servlet?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's exactly right.

There's even an example of this in the struts-examples.war file that comes with the download. Check out org.apache.struts.webapp.exercise.ImageAction.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic