aspose file tools*
The moose likes JSP and the fly likes How do you compare a string using this... 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 "How do you compare a string using this..." Watch "How do you compare a string using this..." New topic
Author

How do you compare a string using this...

Joah Nguyen
Greenhorn

Joined: Aug 29, 2003
Posts: 5
Hello everyone,
This is my first post on the JAVARANCH and hopefully many more to come, I would like to know how would use an if statement like:

I am using an array here below and want to achieve the same result
as the bottom if statement. I am trying to check and see if
show_type.get(i) matches a string, but I do not know the correct syntax.
<% if ( show_type.get(i)"not sure how to code goes right here" ) { %>
blah blah blah
<% } %>
I am trying to achieve the result similar to the example below:
<% if ( show_type.equals( "Y" ) ) { %>
blah blah blah
<% } %>
Hope yall Can helP!..Thanks!


Johnny Apple Seed
Charles Hasegawa
Ranch Hand

Joined: May 22, 2003
Posts: 117
Originally posted by Johnny T:
I am using an array here below and want to achieve the same result
as the bottom if statement. I am trying to check and see if
show_type.get(i) matches a string, but I do not know the correct syntax.
Hope yall Can helP!..Thanks!

Assuming that show_type.get(i) returns a string value, then you would use
Joah Nguyen
Greenhorn

Joined: Aug 29, 2003
Posts: 5
Think I tried that out, but I'll try it again thanks!....Charles
Scott Duncan
Ranch Hand

Joined: Nov 01, 2002
Posts: 363
Johnny, You say you are using an array but show_type.get(i) would indicate that you are using a Vector or ArrayList. Please clarify.
If using an ArrayList:
if(show_type.get(i).toString().equals("Y")){
...
}
or
if(((String)show_type.get(i)).equals("Y")){
...
}


No more rhymes! I mean it!<br /> <br />Does anybody want a peanut?
Joah Nguyen
Greenhorn

Joined: Aug 29, 2003
Posts: 5
Thanks, I am using an ArrayList! I'll will try that out Thanks Again
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61430
    
  67

Welcome to the Ranch Johnny T!
You'll find this forum a great place to seek help on JSP pages, and there aren't many rules you'll have to worry about, but one is that proper names are required. Please take a look at the JavaRanch Naming Policy and change your display name to match it.
Thanks!
bear
JSP Bartender
[ August 29, 2003: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do you compare a string using this...