• 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

Prevent Null from appearing?

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Bartender
Posts: 2661
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dhanush,

How are you displaying your values at the JSP? Are you using JSTL? If you use <c:out>, 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!
reply
    Bookmark Topic Watch Topic
  • New Topic