jQuery in Action, 2nd edition*
The moose likes Java in General and the fly likes Captcha problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Captcha problem" Watch "Captcha problem" New topic

Captcha problem

premchand Singh

Joined: Mar 12, 2012
Posts: 28
hi how to generate a Captcha imge code using java code, can anybody please help me..
the code i have done is not able to upload it here so i am giving you the url plse look and suggest.


Can anybody please help me..
Thanks in advance:
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074

premchand Singh wrote:i am getting error on the line where the code is like this :

String captcha = String.copyValueOf(data[index]);

Please TellTheDetails - what error are you getting exactly?

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
premchand Singh

Joined: Mar 12, 2012
Posts: 28
thanks Jesper de Jong for taking interest in my topic...

java.lang.ArrayIndexOutOfBoundsException: 330
at com.unisys.captcha.CaptchaServlet.processRequest(CaptchaServlet.java:102)
at com.unisys.captcha.CaptchaServlet.doGet(CaptchaServlet.java:121)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

this is the error i am getting.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074

Do you know what ArrayIndexOutOfBoundException means? If not, look it up in the API documentation.

Some hints:

What happens if you have an array with N elements, and you try to access an element with an index outside the range 0 ... N-1?
What do you think you'd need to do to prevent the problem?
Are you literally using the code on that website? How is the value of index detemined (look a few lines above the line that gives you the error)? How many elements does data have?
premchand Singh

Joined: Mar 12, 2012
Posts: 28
hi thanks for yr reply..
that problem got solved but main motto output that i want from the program is still not displaying. i have given the following random numbers to generate the images...


but the image is not being displayed only the first letter is coming on the screen, but what i want is to display the random numbers what ever i have given in the sequence in the code.

Rob Spoor

Joined: Oct 27, 2005
Posts: 19651

premchand Singh wrote:yr

Please UseRealWords: "your", not "yr".

How To Ask Questions How To Answer Questions
I agree. Here's the link: http://aspose.com/file-tools
subject: Captcha problem
Similar Threads
captcha, using simple servlet and struts mapping
A more readable captcha
simple change to code that uses HTTPUrlConnection to make post request to a form
how do validation captcha
JavaScript is not running on IE8