GeeCON Prague 2014*
The moose likes JSP and the fly likes Conditions on field Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "Conditions on field" Watch "Conditions on field" New topic
Author

Conditions on field

Mike Jenkins
Ranch Hand

Joined: Jul 23, 2006
Posts: 57
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

Joined: Jan 10, 2002
Posts: 61310
    
  66



Is this the right way to do String comparisons in Java?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mike Jenkins
Ranch Hand

Joined: Jul 23, 2006
Posts: 57
I am not sure how would I do String comparison?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61310
    
  66

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

Joined: Jul 23, 2006
Posts: 57
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

Joined: Jul 23, 2006
Posts: 57
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

Joined: Jan 10, 2002
Posts: 61310
    
  66

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Conditions on field