Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Conditions on field

 
Mike Jenkins
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am processing form values using Enumeration class in a JSP and would like to know how to deal with fieldnames I dont want.
In the below I dont want to display FieldA but the output shows it even when I try and write condition for it:


Output:
FieldCC
FieldA
OtherField
aField
..more fields etc..

The FieldA should not output.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64833
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Is this the right way to do String comparisons in Java?
 
Mike Jenkins
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure how would I do String comparison?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64833
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you new to Java?

In Java, the == operator (and its relations like !=) is a test for identity, not for equality. It asks, "are these objects the same?". It does not ask "do these objects have the same value?"

For that, you need to use the equals() method of String.
[ March 02, 2007: Message edited by: Bear Bibeault ]
 
Mike Jenkins
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for quick reply!

I tried this and it still not working:


It still outputs:
Output:
FieldCC
FieldA
OtherField
aField
..more fields etc..
[ March 02, 2007: Message edited by: Mike Jenkins ]
 
Mike Jenkins
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry to take your time.

It did work:

I had a misspelling.
I printed the article about the equals() method and I appreciate your reponses and time!
[ March 02, 2007: Message edited by: Mike Jenkins ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64833
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No problem, it's what Javaranch is for.

I'd strongly suggest beefing up your Java skills before delving much more deeply into JSP. You'll find that time well spent.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic