Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to replace a null with blank in jsp table

 
Rakesh Keerthi
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 179
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rakesh Keerthi
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 179
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Pablo Abbate
Ranch Hand
Posts: 30
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64972
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you were using the EL rather than obsolete scriptlets, this would be automatic.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic