aspose file tools*
The moose likes JSP and the fly likes how to avoid displaying 'null' in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "how to avoid displaying Watch "how to avoid displaying New topic
Author

how to avoid displaying 'null' in jsp

Madhu Sudhana
Ranch Hand

Joined: Apr 16, 2006
Posts: 127
I am retrieving data from data base and displaying the same in a jsp in String format.
but when there is no entry for the corresponding field it is getting displayed as null in the jsp.
How can I avoid that ?
I need to display an empty field if the corresponding value is null.


"And the trouble is, if you don't risk anything, you risk even more." -- Erica Jong.
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Use if condition and put empty where it is null.

FE,

abhishek gowlikar
Greenhorn

Joined: Aug 17, 2006
Posts: 13
Here it is simple

when try to retrive the Field from Database,But the Field is Empty
Check the condition like

if(object.variable == null)
{
object.variable="";
}
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
You can have a few utility methods defined in some utility class to get around this issue or anyother related issues.

Or using JSTL is your best bet.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to avoid displaying 'null' in jsp