Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception

 
Deepa Krishnan
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getting java.lang.StringIndexOutOfBoundsException when doing this

I am sending like this from jsp
<input name="SUBPROGRAM_CD" type="hidden" value=''>
Ejb receiving it like this

char subprogCode;

subprogCode=((String)request.get("SUBPROGRAM_CD")).charAt(0);
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the "value" attribute is the empty string, then it's not surprising that the string has no character 0 -- it has no characters at all, right?
 
Deepa Krishnan
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah,you are right.
As per the requirement,i might be a space or a character.
can you suggest another way of converting that into a char.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it's a space, that's fine. But if it's zero length, then you have to check for that before calling charAt(0), of course.

 
Deepa Krishnan
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Friedman-Hill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic