if object is not created it will refer null.
you can't compare null with equals or .length method.

-----Original Message-----
From: Fengrui Gu [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 13, 2000 11:40 AM
To: [EMAIL PROTECTED]
Subject: Re: checking for null password


There is a common mistake here.
"if (pswd==null) ..." never works for checking null value of a string.
As you know, paswd is a reference(from the point of compiler) to the object.
pswd just refers to an String object which has null value. It can not be a
null value.
Either use equals method of String or use length method.

At 02:49 PM 1/13/00 +1000, you wrote:
>Gidday Harish
>You need to check the length of the parameter as well, an empty field(
>e.g. value="") sends a empty not a null string.
>
>int minPassLen = 6; // this is up to you
>if (pswd==null || pswd.length() < minPassLen) {//show the login page
>again with a error message}
>
>cheers pb..
>
>Harish Satyanarayanrao wrote:
>>
>> Hi,
>>
>> I have a problem in a servlet which i wrote.
>>
>> The servlet accepts a username and password from a HTML form.
>>
>> I am accessing the same using getParameter function in the doGet
function.
>>
>> String pwsd = request.getParamater("PASSWORD");
>>
>> To check if the user pressed the submit button without entering the
password,
>> I tried
>> if (pswd==null) {//show the login page again with a error message}
>>
>> The program does not enter this if loop .
>> (The string pswd is getting assigned a value if i do enter the password
in the
>> HTML form)
>>
>> Am i missing something?
>>
>> Harish
>>
>> ____________________________________________________________________
>> Get free email and a permanent address at http://www.netaddress.com/?N=1
>>
>>
___________________________________________________________________________
>> 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
>
>--
>
>
>
>Peter Blakeley
>Head of Software Development Coolcat Software Pty. Ltd.
>http://www.coolcat.com.au/
>Director Bug Audit Services
>http://www.coolcat.com.au/bug_audit
>Director Clearwater WebTech Pty. Ltd.
>
>
>A financial instrument is a device used by a Banker to pick your pocket.
>It is said an art degree is a licence to know it all, I am lucky I need
>no art degree.
>;-})
>
>___________________________________________________________________________
>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
>

___________________________________________________________________________
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

___________________________________________________________________________
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

Reply via email to