Replace null value with blank space

Discussions

Web tier: servlets, JSP, Web frameworks: Replace null value with blank space

  1. Replace null value with blank space (2 messages)

    In my application I have a combo box ,and its populted with all the data but in this combo box there is a null value
    as well ,when nothing is selected or something is selected the combo box value is seen as null though when I am selecting
    some value from combo box I am able to select and insert it.Here I want to remove this null value  or replace it with a blank space .

     

    <tr>
        <td align="left"><font size=4>courses</font></td>
       <td> <select ID="courses" name="courses" onchange="return fncGetemp();">
       <option>Select One</option>
        
        <%
        
         String rec_test="SELECT distinct courses from libraryrecords";
                          
        
         try {
          stmt=con.createStatement();
          ResultSet rs_test=stmt.executeQuery(rec_test);
           String temp = null;
         while(rs_test.next())
         {
         %>
                      
      
                        <option SELECTED value=<%= rs_test.getString(1) %>> <%= rs_test.getString(1) %></option>

       
         <%}
         }
          catch(Exception e){
          System.out.println(e);
         }
        %>
       </select>
       </td>
       </tr>

    Thanks for your time and help :)

    Threaded Messages (2)

  2. Replace null value with blank space[ Go to top ]

    First, don't make db connections in a jsp. It's possible but it's bad practice. To solve youre problem you can store the result of the query in a list an iterate over the list. If the values are null you can replace it with "". Another thing you can do is use NVL function in youre sql. http://www.w3schools.com/SQL/sql_isnull.asp
  3. Thanks[ Go to top ]

    Thanks alot Robby:)
    I will implement this.