Purav,

The issue you are running into is that you really need to test for 2
distinct cases:
a) where name is null and
b) where name is "" (or any number of blanks).

There are a number of different ways to do this, but the following approach
will work...

if (name!=null && name.trim().length()>0)
    System.out.println("We got a non-blank value");
else
    System.out.println("We encountered null or blanks");

Christian
------------------------------------------------
Christian Cryder
Software Engineer, R&D, Vertical Prod.
Lutris Technologies, Inc.
[EMAIL PROTECTED]
------------------------------------------------
       "What a great time to be a Geek"
------------------------------------------------
 http://www.lutris.com ~ http://www.enhydra.org
           http://www.granitepeaks.com

> -----Original Message-----
> From: A mailing list for discussion about Sun Microsystem's
> Java Servlet
> API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of
> SSingh
> Sent: Wednesday, August 16, 2000 3:38 AM
> To: [EMAIL PROTECTED]
> Subject: Re: getParameter method return null string
>
>
> Hi all,
>    In the code below. Even if the value of Name string is
> "null" , then what
> would be the interpretation. It will go in if block . But our
> intension is
> to check for null . So please verify the behaviour.
> Siddhartha Singh
> ----- Original Message -----
> From: Purav <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, August 16, 2000 2:46 PM
> Subject: Re: getParameter method return null string
>
>
> > Hi,
> >
> > So if I write
> >  if(Name.equals("null"))
> >     System.out.println("I have already invested in a Java book");
> >  else
> >     System.out.println("But Still I am Confused");
> >
> > will it work?
> >
> > Purav
> >
> >
> > ----- Original Message -----
> > From: "David Concannon" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Wednesday, August 16, 2000 11:00 AM
> > Subject: Re: getParameter method return null string
> >
> >
> > > try
> > >
> > > if(Name.equals("null"))
> > >    System.out.println("I need to invest in a Java book");
> > > else
> > >    System.out.println("Or look at the API");
> > >
> > >
> > >
> > > -----Original Message-----
> > > From: Purav [mailto:[EMAIL PROTECTED]]
> > > Sent: Wednesday, August 16, 2000 9:55 AM
> > > To: [EMAIL PROTECTED]
> > > Subject: [SERVLET-INTEREST] getParameter method return null string
> > >
> > >
> > > Hi,
> > >
> > > The Request.getparameter() method return null string when
> it does not
> find
> > > the parameter. it does not return null as a keyword
> > >
> > > so if i write
> > > String Name=Request.getParameter("Name");
> > > if(Name==null)
> > >   then something....
> > >
> > > It doesnt work
> > >
> > > I am little confused
> > >
> > > Can anybody help me out
> > >
> > >
> > > Purav
> > >
> > >
> >
> ______________________________________________________________
> _____________
> > > 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
> >
> >
> > ***********************************************************************
> > Privileged/confidential information may be contained in this message.
> > If you are not the addressee indicated in this message (or responsible
> > for delivery of the message to such person), you may not copy or
> > deliver this message to anyone. In such case, you should destroy this
> > message and notify the sender and [EMAIL PROTECTED]
> > immediately.
> >
> > If you or your employer do not consent to Internet E-mail messages of
> > this kind, please advise us immediately.
> >
> > Opinions, conclusions and other information expressed in this message
> >  (including any attachments) are not given or endorsed by ebeon ltd
> >  (or ebeon inc., as applicable) unless otherwise confirmed in writing
> > by an authorised representative independent of this message. Any
> > liability arising from reliance placed on this message (including its
> > attachments) without such independent confirmation is hereby excluded.
> >
> > This message (including attachments) is protected by copyright laws
> > but has no other legal or contractual standing. The presence of this
> > footnote indicates that this message (including its attachments) has
> > been processed by an automated anti-virus system; however it is the
> > responsiblity of the recipient to ensure that the message (and
> > attachments) are safe and authorised for use in their environment.
> > ***********************************************************************
> >
> >
>
___________________________________________________________________________
> > 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

___________________________________________________________________________
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