Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-10-2011, 08:50 AM   PM User | #1
maria_megha
New Coder

 
Join Date: Dec 2010
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
maria_megha is an unknown quantity at this point
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?
maria_megha is offline   Reply With Quote
Old 03-10-2011, 05:36 PM   PM User | #2
spchinta
New Coder

 
Join Date: Mar 2011
Location: USA
Posts: 23
Thanks: 0
Thanked 1 Time in 1 Post
spchinta is an unknown quantity at this point
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.
spchinta is offline   Reply With Quote
Old 03-11-2011, 12:13 PM   PM User | #3
servlet
Regular Coder

 
Join Date: Jan 2009
Location: india
Posts: 145
Thanks: 0
Thanked 5 Times in 5 Posts
servlet is an unknown quantity at this point
Your code should work just fine, and print empty string instead of null.
Where's the problem ?
servlet is offline   Reply With Quote
Reply

Bookmarks

Tags
jsp

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:23 AM.


Advertisement
Log in to turn off these ads.