• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need help in JSP

 
Kartik Tal
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Am having a code in JSP, where for one attribute am getting null so its throwing an exception.



For the attribute "uomCharacter" am getting null and its throwing an exception,so in JPS I need to check if its having value then this option else another option.
Please help me how to write the logic for this, as am new for this.

Regards,
Kartik
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure that the "uomCharacter" property is null and not the iterator variable "i" ?
 
Kartik Tal
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I am sure ,uomCharacter is null not the iterator variable i
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then, try this:

 
Kartik Tal
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sagar,

Am already getting uomCharacter as null, then in your logic


Here itself it will give null pointer exception, as we are checking (i.null)
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kartik Talasu wrote:Here itself it will give null pointer exception, as we are checking (i.null)

Can you post the bean on which you're iterating ? I really don't understand how you get a property as a "null" and not its value ? Is "uomCharacter" a map value ?
 
Kartik Tal
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes uomCharacter is a map value, in my bean class am having 3 variables time,key and uomCharacter.
Which i mapped them with db values.
For uomCharacter am getting null as i dont have any value in db.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, then try using "empty" operator.


"empty(i.uomCharacter)" will return true if i.uomCharacter is null.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to JSP; this is not related to Struts.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic