This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JSP and the fly likes How to replace a null with blank in jsp table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to replace a null with blank in jsp table" Watch "How to replace a null with blank in jsp table" New topic
Author

How to replace a null with blank in jsp table

Rakesh Keerthi
Ranch Hand

Joined: Jul 16, 2012
Posts: 136
Hi,

i am using the below code to display oracle table data on jsp.




it is working fine but in the output table Query_Answered and TR are displaying null(which is correct), what i want is to replace that null with a blank cell. could you please let me know how do i do it.

Thanks
Vishal Shaw
Ranch Hand

Joined: Aug 09, 2012
Posts: 179
Rakesh Keerthi wrote:Hi,

i am using the below code to display oracle table data on jsp.




it is working fine but in the output table Query_Answered and TR are displaying null(which is correct), what i want is to replace that null with a blank cell. could you please let me know how do i do it.

Thanks


It's a bad idea writing your business logic inside jsp.


Programming is about thinking, NOT coding
Rakesh Keerthi
Ranch Hand

Joined: Jul 16, 2012
Posts: 136
i'll be moving it into a servlet soon. but please let me know how do i change null to a blank
Vishal Shaw
Ranch Hand

Joined: Aug 09, 2012
Posts: 179
Rakesh Keerthi wrote:i'll be moving it into a servlet soon. but please let me know how do i change null to a blank


In the Servlet you can create your own method to handle null. Then for each data fetch, you can use the created method to handle it.

Say for example


Then replace getString() by replaceNull(getString())
Eswar Nec
Ranch Hand

Joined: May 02, 2010
Posts: 105
Temporary assigned into one variable.

Check whether the string is null or not.

If null then write code for empty tag. otherwise display the content.


Wake up! Don't let your smile be snatched away by anybody!
Regards, Eswar
Pablo Abbate
Ranch Hand

Joined: Aug 06, 2012
Posts: 30

If you want some quick solution ...

<%if(rs.getString("Query_Answered") != null){%>
<td><%=rs.getString("Query_Answered")%></td>
<%}
else{%>
<td></td>
}%>

Please check the syntax because I didn't


Nissi Group, Posicionamiento Web, Desarrollo de Software, DiseƱo Web
Blog , LinkedIn
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61084
    
  66

If you were using the EL rather than obsolete scriptlets, this would be automatic.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to replace a null with blank in jsp table