Sorry, just figured it out, easy enough really, all I did was
converted errs to a new string and checked if that had nothing in.
-----Original Message-----
From: Sam Rose
Sent: Monday, August 09, 1999 9:14 AM
To: 'Java Servlet Mailing List'
Subject: stringbuffers
Hello people,
I am stuck with this bit of coding involving a stringbuffer,
Basically the string buffer has all the messages put into it if the
user has missed out some of the form fields.
But the problem is when the user has actually filled in all the
fields, and still gets the message "You have forgotten these fields ",
and a blank after it, so the errs string buffer is empty, but I can't
see why "everythings fine" is not printed out.
Any help will be gratefully received...
StringBuffer errs = new StringBuffer();
if (firstname.equals("")){errs.append("Firstname, ");}
if (surname.equals("")){errs.append("Surname, ");}
if (email.equals("")){errs.append("Email, ");}
if (user.equals("")){errs.append("Username, ");}
if (password.equals("")){errs.append("Password, ");}
if (conpassword.equals("")){errs.append("Confirming the Password,
");}
if (!(password.equals(conpassword))){errs.append(" The passwords do
not match");}
if (errs.equals("")) {
out.println("everythings fine");
}
else {
out.print("You have forgotten these fields " + errs);
Cheers
Sam Rose
___________________________________________________________________________
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