My guess is that p isn't null. It's probably "". Try println("|"+p+"|") to
be sure - if you see ||, it's "".
Anyway, I normally create a static utility method that checks to see that
strings are valid. It checks for the string passed in not being null, and
not of zero length and returns true if both are true, otherwise false. Sort
of like the perl method defined.
Then, I would do
if(Utils.valid(p))
{
// do something
}
else
{
// p was either null or zero length
}
hope that helps.
- gene
----- Original Message -----
From: "irene_plj asiamail.com" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, April 03, 2001 7:57 PM
Subject: Simple Problem....
> Hi all ,
>
> The problem wf the below code(part of my servlet)is i always get the "if"
condition even if it "p" equals null..
> Wat could be wrong???
> This is such a simple problem but i jus cannot get the "else" condition
when p==null.
> Anyone any idea why this cannot work??
> Thks .
>
> ******************************************
> ..
> ..
> try
> {
> String p=request.getParameter("ID");
> if(p != null)
> {
> String to=p+"@asiamail.com";
> }
> else
> {
> String to="[EMAIL PROTECTED]";
> }
>
> }
> ..
> ..
> **********************************************
> --
>
> _______________________________________________
> Get your free email from http://freemail.asiamail.com
>
>
___________________________________________________________________________
> 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