Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Dec 2010
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    handling nulls in jsp textbox

    Hi how can I replace "null" from being displayed with an empty string in a textbox on the JSPs ..depending on textbox data availability..
    I tried the code below but still it displays null

    Code:
    <% String phone=userInfoObj..getPhoneno();
    if(phone==null||phone.equalsIgnoreCase("null"))
    phone=" ";
    %>
    		
    		<td >
    		<input type="text" name="phoneno" class="txtBox" value="<%=phone %>"></td>
    can you suggest by using java or javascript?

  • #2
    New Coder
    Join Date
    Mar 2011
    Location
    USA
    Posts
    23
    Thanks
    0
    Thanked 1 Time in 1 Post
    What is the value returned by userInfoObj..getPhoneno()?

    I replaced with String phone= null; in your code and tried. It worked perfectly.
    I didn't see null in text box.

  • #3
    Regular Coder
    Join Date
    Jan 2009
    Location
    india
    Posts
    145
    Thanks
    0
    Thanked 5 Times in 5 Posts
    Your code should work just fine, and print empty string instead of null.
    Where's the problem ?


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •