Try to do this: if ((res.getString(3) != null) && (res.getString(3).length > 0)) { ... }
It is because java.util.String must use its equals() method for string comparison. The only logical operator you can use is for null comparison. Also some database distinguish between empty string '' and null value, just becareful of that! > -----Original Message----- > From: Paul Wallace [SMTP:[EMAIL PROTECTED]] > Sent: Monday, March 11, 2002 3:58 AM > To: Tomcat Developers List > Subject: ResultSet > > Hi, > For the brave, can anyone guess why with this rather unsociable > code: > > > if ((res.getString(3) == null) || (res.getString(3) == "")) { > out.println("<td><a href=takeDetails.jsp?timeSlot=" + > res.getString(2) + "&myDate=" + myDate + ">" + res.getString(2) + > "</a></td>"); > } > if ((res.getString(3) != null) || (res.getString(3) != "")) { > out.println("<td>" + res.getString(3)+ " " + res.getString(2) + > "</td>"); > } > > > the first condition is NEVER satisfied, even though out.println of > res.getString(3) does not display anything! Ie res.getString(3) IS > null, > empty or whatever, but the condition is never satisifed. Quickly > again, this > is executed: > > > if ((res.getString(3) != null) || (res.getString(3) != "")) { > out.println("<td>" + res.getString(3)+ " " + res.getString(2) + > "</td>"); > } > > > even though - out.println("<td>" + res.getString(3)+ " " - shows it > is > empty (no output)! > > Thanks > > Paul. > > > -- > To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>