This will also result in a NullPointerException !

Try:

if (pQ2 == null || pQ2.length() == 0)

I think we had that topic some weeks ago !

Sandeep Malhotra wrote:
>
> compare with null like this ---> if  (pQ2.equals(null))
> // null should not be in quotes while comparison else it be taken as String
>
> ----- Original Message -----
> From: Lambert, Stephen : CO IR <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, April 17, 2000 6:39 PM
> Subject: checking for null in a doPost method
>
> > I'm trying to pass blanks for a null into my db from an html form.
> > Code as follows:
> >
> > String pQ2 = request.getParameter("check2");
> > if  (pQ2.equals("null") {pQ2="";
> > }
> >
> > I end up with the error "java.lang.NullPointerException".
> > Even though when I display the variable pQ2,  it gives me "null"(no
> quotes)
> > using:
> >
> > out.println(pQ2);
> >
> > Anybody know how to check for null data from a doPost method?
> > Thanks,
> > Stephen.
> >
> >
> ___________________________________________________________________________
> > 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
begin:vcard
n:Brune;Henning
tel;fax:+49 (0)5 21/1 06-64 40
tel;work:+49 (0)5 21/1 06-29 48
x-mozilla-html:FALSE
org:Universitaet Bielefeld;Technische Fakultaet, AG TI
adr:;;Postfach 100131;Bielefeld;NRW;33501;Germany
version:2.1
email;internet:[EMAIL PROTECTED]
title:Dipl.-Inform.
fn:Henning Brune
end:vcard

Reply via email to