Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Captcha problem

 
premchand Singh
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15219
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
premchand Singh
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15219
36
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20514
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
premchand Singh wrote:yr

Please UseRealWords: "your", not "yr".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic