wood burning stoves 2.0*
The moose likes Java in General and the fly likes Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Exception" Watch "Exception" New topic
Author

Exception

Deepa Krishnan
Greenhorn

Joined: Feb 25, 2005
Posts: 26
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);


SCJP 1.4
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

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?


[Jess in Action][AskingGoodQuestions]
Deepa Krishnan
Greenhorn

Joined: Feb 25, 2005
Posts: 26
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

Joined: Jul 08, 2003
Posts: 24183
    
  34

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

Joined: Feb 25, 2005
Posts: 26
thanks Friedman-Hill
 
 
subject: Exception
 
Similar Threads
Comments on Tata Indico Car
Inserting table and image into a doc file using hwpf(poi)
The new Moose
things used to get boring on the farm
The x900 effect ?