you should check for null before checking for .equals
eg:
if (password != null && password.equals("forgot"))
go to password forgot page (servletname?password=forgot)
if (user != null && user.equals("new"))
go to the new user sign in page (servlet?user=new)
That is because if the user does not fill in any information or
some such reason, the req will return null and java will throw
nullpointer exception if your string is null and you
exec .equals on it.
> -----Original Message-----
> From: A mailing list for discussion about Sun Microsystem's Java Servlet
> API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of Kerem
> �KTEM
> Sent: Saturday, July 22, 2000 9:59 PM
> To: [EMAIL PROTECTED]
> Subject: null pointer exception
>
>
> hi,
> i know what null pointer exection means but can you suggest me something to
> do in this case.
>
> servlet code includes this
>
> String password=req.getParameter("password");
> String user =req.getParameter("user");
> String error=req.getParameter("error");
>
> if (password.equals("forgot"))
> go to password forgot page (servletname?password=forgot)
> if (user.equals("new"))
> go to the new user sign in page (servlet?user=new)
>
> and also i don't want people to to access (servletname)
> which i think would be suitablt this code
>
> (if password.equals("")&&user.equals(""))
> go to log in page
> likely
> when
> (if password.equals("forgot")&&user.equals("new"))
> go to log in page
>
> all these if statements turn me with null pointer exeception
> PLEASE HELP ME
>
> cause i am gettting much angry about this i have to work with datbase too
> tahnx
>
> Kerem
>
> ___________________________________________________________________________
> 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