• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Captcha problem

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Sheriff
Posts: 22780
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

premchand Singh wrote:yr


Please UseRealWords: "your", not "yr".
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic