• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

How to replace a null with blank in jsp table

 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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())
 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 30
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67618
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you were using the EL rather than obsolete scriptlets, this would be automatic.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic