Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

jsp multiple dynamic construction of checkbox from database records

843838Nov 2 2005 — edited Nov 14 2005
I have a servlet that does a database lookup and then populates a java bean , I then use the data in the java bean to populate a list of checkboxes in a JSP. (the data returned is only one row)



This all works fine as in code below but how do I store the multiple rows from the database and store this and iterate through this to create a dynamic list checkboxes of however many records are returned by the database in the JSP. howdo i do this using servlet / javabean/ jsp

(ie.how do I do

(



in servelt : while resultSet.next()){�populate a collection with all rows returned�}

in jsp; retrive this list and one record ata time create the checkboxes



is there an easy way of doing this � do I use jsp taglib or is it possible just to loop through and pass the object from servlet to jsp � I cant seem to get lots of errors.



)





Servelt relevant code :�..

��

stmt.execute(select);



ResultSet resultSet = stmt.getResultSet();



Abridgment abridgment = new Abridgment();

abridgment.seta_county(county);

abridgment.seta_year_date(Integer.parseInt(year));

// abridgment.a_sub_year_volume = Long.parseLong(c_phone);



if (resultSet.next()){

abridgment.seta_sub_year_volume(resultSet.getInt("a_sub_year_volume"));

abridgment.seta_page_id(resultSet.getString("a_page_id"));

abridgment.seta_month_date(resultSet.getInt("a_month_date"));

abridgment.seta_day_date(resultSet.getInt("a_day_date"));

abridgment.seta_year_sequence(resultSet.getLong("a_year_sequence"));

abridgment.seta_day_sequence(resultSet.getLong("a_day_sequence"));

abridgment.seta_year_volume(resultSet.getInt("a_year_volume"));

abridgment.seta_volume_id(resultSet.getString("a_volume_id"));

abridgment.seta_summary(resultSet.getString("a_summary"));

abridgment.seta_batch_id(resultSet.getLong("a_batch_id"));

abridgment.seta_image_id(resultSet.getLong("a_image_id"));



session.setAttribute("isNewAbridgment", new Boolean(false));

}

else{

session.setAttribute("isNewAbridgment", new Boolean(true));

out.println("<DEBUG> <AbridgmentSearchS-service> Abridgment not found: " + abridgment);

}



session.setAttribute("abridgment", abridgment);





----------------------------------------------------------------------------------------------------------------------------------------

JSP code: ��..



<jsp:useBean id="abridgment" class="com.bt.ros.Abridgment" scope="session">

</jsp:useBean>



</h3>



<form name="myform" method="POST" action="ResultsListShrinkS"

<table>

<tr><td>

<p><input type="checkbox" name="C1" value="Check All" onClick="this.value=check(this.form.list)">Select All</p>

<p><input type="checkbox" name="list" value="ON"><span style="font-size:12pt"><jsp:getProperty name="abridgment" property="a_sub_year_volume"/></span><span style="font-size:12pt">,

<jsp:getProperty name="abridgment" property="a_volume_id"/>, </span><jsp:getProperty name="abridgment" property="a_batch_id"/>,<p:onmouseclick

hyperlinktype="url"

href="file://........tif"/><span style="font-size:12pt;mso-color-index:6"><jsp:getProperty name="abridgment" property="a_image_id"/></span><span style="font-size:16pt;mso-color-index:6"> </span><br>





I have searched the web and cant find anything relevant � can anyof you point me in the right direction or maybe you have done this kind f thing before � can you show me some sample code.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 12 2005
Added on Nov 2 2005
4 comments
263 views