File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes if name.equals( Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "if name.equals("") doesn Watch "if name.equals("") doesn New topic
Author

if name.equals("") doesn't work :[

Katia Platonov
Greenhorn

Joined: Sep 06, 2002
Posts: 13
Hello everyone,
I am stumped
I want to build a column header if anything returned from it from the database and ignore it if it's empty.
I've tried:
if((rs.getString("name").equals(""))
{
out.println("dont' build headers")
}
else
{
out.println("build headers")
}
but it's completely ignoring the logic and builds headers every time.
In my database when I run this query:
select * from user_info where name != ''
users with filled in name column displayed
When I run:
select * from user_info where name = ''
all the rest are displayed.
I do not understand where the problem lies.
Would anybody please help?
Thank you very much.
Katya.
prabhat kumar
Ranch Hand

Joined: Apr 11, 2001
Posts: 114
if the column "name" is isnull field
then use this
if((rs.getString("name")!=null)
{
out.println("build headers");
}
else
{
out.println("dont' build headers");
}
Katia Platonov
Greenhorn

Joined: Sep 06, 2002
Posts: 13
Thank you for replying. You see... this is the problem...
The columns that are empty do not have NULL values.
They look like they have spaces and my query that checks for spaces works, yet name.equals("") doesn't work.
With your solution it will never build headers because those columns are never NULL.
And that is where I'm stumped.
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

Try this:

Rene


Regards, Rene Larsen
Dropbox Invite
Katia Platonov
Greenhorn

Joined: Sep 06, 2002
Posts: 13
It worked!!!
Thank you so so so very much.
Katya.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: if name.equals("") doesn't work :[