Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help looping through Vector to display please.

Status
Not open for further replies.
Jan 8, 2001
163
US
I'm trying to loop through a vector, detokenize it's results and display them in a drop down list box on my jsp page. Unfortunately, it doesn't seem to be looping correctly. My list box displays empty. Does anyone see what I'm doing wrong? I'm new to Vectors so it may be something simple. Thanks!

CrystalVisualBOracle


<% Vector v_companies = new Vector();
UserData DataObj = new UserData();
v_companies = DataObj.Get_Companies();
// This method call returns a filled vector
%>

...
<P><TD NOWRAP=TRUE COLSPAN=3><FONT FACE =&quot;Arial, helvetica&quot; size=-2>COMPANY:
<select NAME=&quot;Company&quot;>

<%
int num_companies = v_companies.size();
for(i=0; i>num_companies; i++) {

String co = (String)v_companies.get(i);

try {
StringTokenizer st_co = new StringTokenizer(co, &quot;{&quot;, false);

while (st_co.hasMoreTokens()) {

String companyname = st_co.nextToken();
String s_compid = st_co.nextToken();
%>

<option VALUE=&quot;<%=s_compid%>&quot;><%=companyname%>
<option VALUE=&quot;1&quot;>IN HERE

<%
}
}
catch (NoSuchElementException ee) {
System.err.println(&quot;No More Elements Found&quot; + ee.toString());}
}
%>

 
for(i=0; i>num_companies; i++) {

should be

for(i=0; i<num_companies; i++) {
 
It may not be this, but it looks like you may be running off the end of the Vector by using a > rather than a < in your 'for' loop.

 
oops, i guess thats what haapens when you take too long answering a thread, some bloke pops in in front without you knowing and makes you look like an idiot for putting the same answer. Oh well, at least is was the same answer, so if its wrong we both look like idiots......::)
 
Doh! Can't believe I did that! Thanks for the keen eyes all. I appreciate your help.

Thanks Again,
CrystalVisualBOracle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top