java - check against empty form field -


i'm pretty new java bear me. i've got simple script processes form data , sends error log. i've got simple null check suppose if phone field isn't filled in don't send error log. reason it's not working. i'm getting in error log string "phone number associated account:" ideas?

string phone = request.getparameter("phonenumber"); string showphone = (phone != null) ? " phone number associated account: " + phone : "";  log.error(showphone); 

i'm not sure framework you're using, null object , empty string not same in java. might want try:

string showphone = (phone != null && phone.trim().length()>0) ? " phone number associated account: " + phone : ""; 

the && phone.trim().length()>0 ensure string has content.


Comments

Popular posts from this blog

Java sticky instances of class com.mysql.jdbc.Field aggregating -