I have tried this for 2 hours , but I've given up. I am checking the value of a String this way:
if(value.equals("")||value.length()<0||value==null)
{
value = "Anynomous"
}
But still the string is printing the value null.
Please see this program code here
<HTML>
<BODY>
<%!
String value ;
%>
<%
value = (String)request.getAttribute("retunval");
System.out.println("Inside New fgdf JSP");
if(value.equals("")||value.length()<0||value==null)
value = "Anonymuos";
%>
Hello <%=value%>
<BR>
</BR>
<BR>
</BR>
<a href="Test.jsp">Try Again</a>
</BODY>
</HTML>
==null. In this case ifvalue == nullyou getsNullPointerExceptionbecause ofvalue.equals("")is executed first.if (value == null || value.length() == 0) value = "Anonymous";should be OK. Likely you set value by string "null" somewhere somehow. For examplevalue = String.format("%s", somethingThatIsNull)will result invalue == "null".