The problem is in your if statement
"if ( _c0 == _x0 )"
You have defined the variables "_c0" and "_x0" to be Java String objects, so
the if statement is comparing to see if these two OBJECTS are one and the
same OBJECT (i.e., are they pointing to the same object?), as opposed to
whether or not the String 'values' these objects hold are equivalent.
To see if the String objects have the same string 'values', you can use the
equals method:
"if ( _c0.equals(_x0) )"
if you don't care about case, you can use the 'equalsIgnoreCase()' method
instead.
-----Original Message-----
From: Jay H. Lang [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 01, 2000 1:41 PM
To: [EMAIL PROTECTED]
Subject: Scriptlet for loop and if statement.
Hi All,
I am using a DataBase Bean to gather data to populate a list box. I
can't seem to get an "if" statement inside of a "for" loop to work. I
know that I have conditions that meet the "if" criteria, but nothing
ever get loaded in my OPTION tag. However, if I remove the "if"
condition, the box loads great.
Hear is the code snippet:
<%
try {
java.lang.String _p0 = CN31CiDBBean.getCITY_CODE(0); // throws an
exception if empty.
java.lang.String _c0 = CN31CiDBBean.getCOUNTRY_CODE(0); // throws an
exception if empty.
java.lang.String _x0 = CN31CiDBBean.getO_COUNTRY_CODE(); // throws an
exception if empty.
%><SELECT name="O_CITY_CODE" size="1"><%
for (int _i0 = 0; ; ) {
if ( _c0 == _x0 ) { %>
<OPTION value="<%= _p0 %>"><%= _p0 %></OPTION><%
}
_i0++;
try {
_p0 = CN31CiDBBean.getCITY_CODE(_i0);
_c0 = CN31CiDBBean.getCOUNTRY_CODE(_i0);
}
catch (java.lang.ArrayIndexOutOfBoundsException _e0) {
break;
}
} %></SELECT><%
}
catch (java.lang.ArrayIndexOutOfBoundsException _e0) {
} %>
Thanks in advance for any help.
--
Jay H. Lang
Chief Technologist
Distributed Computing Professionals Inc.
IBM Certified Specialist - MQSeries
303 277-1873 - Office
303 807-9700 - Cell
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets