0

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

Edited by peter_budo: Keep It Clear - Do wrap your programming code blocks within [code] ... [/code] tags

2
Contributors
4
Replies
7
Views
6 Years
Discussion Span
Last Post by newbeejava
0

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>

Edited by peter_budo: Keep It Clear - Do wrap your programming code blocks within [code] ... [/code] tags

0

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

0

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

Edited by peter_budo: Keep It Clear - Do wrap your programming code blocks within [code] ... [/code] tags

0

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.

Edited by newbeejava: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.