aspose file tools*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Captcha problem" Watch "Captcha problem" New topic
Author

Captcha problem

premchand Singh
Greenhorn

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.

http://kannanking.blogspot.in/2010/06/captcha-using-java-jsp-servlet.html

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

Joined: Aug 16, 2005
Posts: 13868
    
  10

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
Greenhorn

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: 13868
    
  10

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
Greenhorn

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...

{'5','j','1','J','9','k','r'},
{'5','K','z','N','6','F','B'},
{'R','d','G','1','q','9','0'},
{'d','1','4','q','Z','f','m'},
{'v','g','S','u','q','C','s'},
{'o','Q','A','l','r','P','B'},
{'h','u','0','M','4','w','o'},
{'3','5','d','R','P','W','N'},
{'w','C','p','v','Q','7','q'},
{'h','3','z','Z','p','5','y'},
{'K','F','h','O','6','5','T'},
{'D','6','V','b','H','w','j'},
{'r','I','9','A','j','s','Q'}

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
Sheriff

Joined: Oct 27, 2005
Posts: 19541
    
  16

premchand Singh wrote:yr

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


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