• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

How to get a image used in captcha servlet?

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have created java project using struts2 and hibernate 3. I n which I am using a servlet named SimpleCaptcha.
This is the servlet included in " web.xml"::

<servlet>
<servlet-name>SimpleCaptcha</servlet-name>

<servlet-class>nl.captcha.servlet.SimpleCaptchaServlet</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>SimpleCaptcha</servlet-name>

<url-pattern>/simpleCaptcha.jpg</url-pattern>

</servlet-mapping>


The image used in this is i.e "simpleCaptcha.jpg" . I searched for this image in simple catcha libraries that I have included in project but I am not
getting the image. I want to increase the font size used in the captcha image.
How can I do this ,can anyone will help me?
 
Sheriff
Posts: 67590
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In a captcha system, I would assume that the image is automatically generated at run time.
 
sarita chaudhary
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, the image is generated during runtime in captcha system .This means we cannot change or increase the
font size used in the captcha image?
Is there any solution to do this.
 
Bear Bibeault
Sheriff
Posts: 67590
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would assume that if the captcha system allows for that that it would be present in the API.
 
sarita chaudhary
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I searched for the image in the API but I did not get that.What is the exact location of the image in the API?
How to get that, to make any changes?
 
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think you understand how captchas are generated. What program/library are you using to generate the captcha? Give us a link to the home page and/or documentation of the captcha library.
 
sarita chaudhary
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The API that I have included in web.xml :::

<welcome-file-list>
<welcome-file>/login.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>SimpleCaptcha</servlet-name>

<servlet-class>nl.captcha.servlet.SimpleCaptchaServlet</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>SimpleCaptcha</servlet-name>

<url-pattern>/simpleCaptcha.jpg</url-pattern>

</servlet-mapping>


The jsp that I have used is 'index.jsp' in that the part is ::::

<%@ page import="nl.captcha.Captcha"%>

<tr>

<td align="left" bgcolor="#F7BE81">
Verification Code <label style="color: red">*</label> :</td>
<td class="bg_captcha" bgcolor="#F7BE81"><img id="captcha" src="simpleCaptcha.jpg" width="150"></td>
</tr>


The libraries that I have used for Simple captcha are:::

standard.jar
simplecaptcha-1.1.1.jar
jstl-1.2.jar
imaging.jar
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The documentation of that library has hints on how to change the font (size). Start from here http://simplecaptcha.sourceforge.net/custom_images.html which explains how to customize the images and then look at the javadoc of Captcha.Builder http://simplecaptcha.sourceforge.net/javadocs/nl/captcha/Captcha.Builder.html which has this method http://simplecaptcha.sourceforge.net/javadocs/nl/captcha/Captcha.Builder.html#addText%28nl.captcha.text.producer.TextProducer,%20nl.captcha.text.renderer.WordRenderer%29 where you can pass a custom WordRenderer implementation which uses it own font and size. By default, it looks like the DefaultWordRenderer http://simplecaptcha.sourceforge.net/javadocs/nl/captcha/text/renderer/DefaultWordRenderer.html which even has a constructor which accepts the fonts that you wish to pass.


 
reply
    Bookmark Topic Watch Topic
  • New Topic