> The algorythm below will check two strings for equality, but I think I
> need to use String.equals("value") to check if a string = a value,
> such as null. However, when I do that it throws a null point
> exception, becuase String is null.
if you d a String.equals(null), you are passing a null object to the
equals function which was expecting a valid string object and hence the
exception.
you dont get an exception for String.equals("value") because '"value"' is
converted to string object by the compiler. you might want to try to do a
.equals("") if you want to check if the string contains nothing. (better
way would be to check its lenght and im not even sure if this would work)
aditya
here is the equals defn:
equals
public boolean equals(Object anObject)
Compares this string to the specified object. The result is true if
and only if the argument is not
null and is a String object that represents the same sequence of
characters as this object.
Overrides:
equals in class Object
Parameters:
anObject - the object to compare this String against.
Returns:
true if the String are equal; false otherwise.
>
> Any ideas?
>
> John D. McDonald
> CipherStream Systems
> Phone: 925.373.8700
> Fax: 413.793.6603
> email: [EMAIL PROTECTED]
> web: www.cipherstream.com
> -------------------------------------------------------
> Secure E-Business Is Our Business
> -------------------------------------------------------
> ----- Original Message -----
> From: Erik Sahl
> To: John McDonald ; [EMAIL PROTECTED]
> Sent: Wednesday, January 05, 2000 3:37 PM
> Subject: RE: Checking for null
>
>
> You mean like...
>
> String myValue = req.getParameter("value");
>
> if (myValue != null)
> {
> ...continue execution
> }
>
>
> -----Original Message-----
> From: A mailing list for discussion about Sun Microsystem's Java Servlet API
>Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of John McDonald
> Sent: Wednesday, January 05, 2000 4:03 PM
> To: [EMAIL PROTECTED]
> Subject: Checking for null
>
>
> I am retrieving a value from a web page with req.getParameter("value"). How do I
>check if the string is null without getting a null pointer exception. Any ideas would
>be helpful.
>
>
> John D. McDonald
> CipherStream Systems
> Phone: 925.373.8700
> Fax: 413.793.6603
> email: [EMAIL PROTECTED]
> web: www.cipherstream.com
> -------------------------------------------------------
> Secure E-Business Is Our Business
> -------------------------------------------------------
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html