• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Conditions on field

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not sure how would I do String comparison?
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic