Populating drop down menu's from database dynamically

Hi

I m facing a problem of populating the drop down menu from a MS Access database using JSP. But i m not able to do it. Can you please help me out?

this works perfectly for textarea

<textarea cols="20" rows="20">

<% for(int i =1; i <=rsmd.getColumnCount();++i)

out.println(rsmd.getColumnName(i)); %>

</textarea>

but for drop down box it gives problems

Heres the code!

<select name="aa" ID = "aa">

<option value="<% for(int i =1; i <= rsmd.getColumnCount();++i)

out.println(rsmd.getColumnName(i)); %>" > </option>

</select>

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 61 in the jsp file: /gv/event.jsp

Generated servlet error:

i cannot be resolved

wat can be the alternative? Please hlp

Regards

Sami

[925 byte] By [sami_azmia] at [2007-11-26 17:46:29]
# 1
<select><%for(int i =1; i <= rsmd.getColumnCount();++i){%><option value="<%=rsmd.getColumnName(i)); %>" ></option><%}%></select>MeTitus
Me_Titusa at 2007-7-9 4:58:38 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

sorry but it gives this error now!

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 64 in the jsp file: /gv/event.jsp

Generated servlet error:

Syntax error on token ";", delete this token

and after deleting, which is syntactically incorrect it doesnt work!

Message was edited by:

sami_azmi

sami_azmia at 2007-7-9 4:58:38 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
<option value="<%=rsmd.getColumnName(i))%>" MeTitus>
Me_Titusa at 2007-7-9 4:58:40 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
<option value="<% out.write(rsmd.getColumnName(i))) ; %>">Message was edited by: Sudhir_nimavat
Sudhir_nimavata at 2007-7-9 4:58:40 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

Thanks for the reply,

Every thing is now error free But the problem still remains.

the values are not shown in the dropdown menu, no value is added in it. i tried adding value of i that too was not shown, i donno wat the problem can be.

these Codes were used and they are working without error.

<select>

<option value= "-">-

<% for(int i =1; i <= rsmd.getColumnCount();++i) { %>

<option value="<% out.write(rsmd.getColumnName(i)); %>" > </option>

<% } %>

</select>

<option value="<%=rsmd.getColumnName(i))%>"

can u pls suggest the remedy!

Sami>

sami_azmia at 2007-7-9 4:58:40 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

<option value="<% out.write(rsmd.getColumnName(i)); %>" > </option>

should be

<option value="<% out.write(rsmd.getColumnName(i)); %>" >

<% out.write(rsmd.getColumnName(i)); %></option>

the value= is what is returned to you when they select it, the second one before the </option> is what they see. That way they don't have to be the same ie

the value could be "bc" and the option they see is "Britsh Columbia"

Lena

LenaBa at 2007-7-9 4:58:40 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
hi all and thanks a lot.its working now.
sami_azmia at 2007-7-9 4:58:40 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...