html - What is the difference between null and "" -
i trying understand jsp codes of guy having trouble following codes:
if( request.getparameter("username")!=null && !request.getparameter("username").equals("")) the username field user fills on html form. codes after these codes saves data user fills in strings later used other purposes.
my question purpose of !request.getparameter("username").equals("") code part in above?
has request.getparameter("username")!=null part of code not tested whether user enters information input field of html form or not?
regards
if reveive request like
http://.../yourservlet then parameter value null, since no parameter named username passed @ all.
if reveive request like
http://.../yourservlet?username= then parameter value empty string, since parameter passed, value empty string.
what you'll receive depends on html, , on user (he type url manually in address bar, example). code makes sure both cases handled in same way. let's imagine javascript in page disabled input field or removes dom when checkbox checked. in case, parameter won't sent @ all.
Comments
Post a Comment