• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to get a image used in captcha servlet?

 
sarita chaudhary
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • 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?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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?
 
J. Kevin Robbins
Bartender
Posts: 1801
28
Chrome Eclipse IDE Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • 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.


 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!