Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Prevent Null from appearing?

 
dhanush karma
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I prevent the word "null" from appearing in my HTML input text fields when I populate them with a resultset that has null values?
[ March 23, 2007: Message edited by: Bear Bibeault ]
 
Jan Cumps
Bartender
Posts: 2608
14
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use java.sql.ResultSet.wasNull().
This method reports whether the last column read had a value of SQL NULL.

Call it after you have retrieved a column value.
Only print the value you returned when wasNull() returns false.

pseudocode:Regards, Jan
[ March 23, 2007: Message edited by: Jan Cumps ]
 
Chengwei Lee
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dhanush,

How are you displaying your values at the JSP? Are you using JSTL? If you use <cut>, I believe it handles NULl values for you gracefully. Alternatively, if you're using scriptlets to display the values, you could check for null before printing.

You should follow the MVC pattern. Handling the display of null values belongs to the presentation layer.

Cheers!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic