Hi
I am doing a java program.
In which I have a jsp page, and on that I have two combobox.
I have a create a java bean, in which I write a method "result" which return a arraylist.

I want to populate the combobox by extracting data from database. which I have extarcted from in javabean.

<select name="day">
                    <option value="<%= JdbcQueryBean.result() %>"><%=JdbcQueryBean.result()%></option>
                </select>

But this command showing all the value in one row, not in the from of list.

Please help.

can anyone suggest me some JSTL for this
Thanks in advance

Recommended Answers

All 4 Replies

Hi newbeejava,

This is the JSTL code to populate the combobox ....

<select id="day" name="day" >
<c:forEach var="daylist" items="<%=JdbcQueryBean.result()%>">
<option value='<c:out value="${daylist}" />'><c:out value="${daylist}" /></option>
                  </c:forEach>
                </select>

Hi
As you have suggested, I have written the code

<td><select id="subject" name="subject">
 <c:forEach var="st" items="<%=JdbcQueryBean.result()%>">
            <option value='<c:out value="${st}"/>'><c:out value="${st}"/></option>
       </c:forEach>

But it does not displaying the value

I have checked that it extracting the data from the database properly.
If I am writting this code

<select name="day">
                    <option value="<%= JdbcQueryBean.result() %>"><%=JdbcQueryBean.result()%></option>
                </select>

It displaying all the values in one row, not in column.

Please suggest

Hi newbeejava,

u can call the function which u wrote (JdbcQueryBean.result())and assign it to ArrayList variable like this

ArrayList  daylist = JdbcQueryBean.result();

and check the values are coming or not...

if the values are coming then write this code ...

<select id="day" name="day" >
       <c:forEach var="datItem" items="<%= daylist %>">
              <option value='<c:out value="${datItem}" />'>
              <c:out value="${datItem}" /></option>
       </c:forEach>
                </select>

It works fine for me ,if it is not working for u then post ur jsp page & class the function which u are calling, i will check it

Thank you very much, your code is working fine.

I am very new to java, I am not asking you for code, but can you give me some idea, how to display a result set(extracted from data base) e.g-"select * from emp", in the form of data grid in a jsp page.

I want to know is there any control like memory table(data table) in java and for displaying datagrid?
I have written a bean for data extraction and all, so how can I store my data in the memory table and display that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.