Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The code I have written gives me the output of only a single data in the drop down list. I want my drop down list to retrieve and hold all the data of the fname and userid column of the table. I am using struts concept and JSP. Kindly help as to how I should modify my code?

Java
public String subjectAllocation2()throws Exception
      {
      try{

     Map session=ActionContext.getContext().getSession();
     Long idd=(Long)session.get("USERID");

     System.out.println("sss"+idd);
     ResultSet rs=ConnectionDb.getStatement().executeQuery("select USERID,FNAME from DIP_FACULTY"); 
     ResultSetMetaData metaData = rs.getMetaData();
     int columns = metaData.getColumnCount();
     ArrayList al = new ArrayList();
     while(rs.next())
     {

           for (int i = 1; i <= columns; i++)
           {
             String value1 = rs.getString(i);
             al.add(value1);
           }
           setUserid(rs.getString(1));
           setFname(rs.getString(2));
       System.out.println("The details="+rs.getString(1)+rs.getString(2));      

}
catch(Exception e)
{
   System.out.println("exception");
}
return "subjectAllocation2";
}

and this is the jsp code:
<s:form action="addSubject" method="post"  enctype="multipart/form-data">
                <table border="1" cellpadding="15" width="300">

                <tr><td><s:combobox name="semestar" label="Semestar" list="    {'1st','2nd','3rd','4th','5th','6th','7th','8th'}"></s:combobox></td>
                <td><s:combobox name="branch" label="Branch" list="{'CSE','IT','EEE','ETC','MECH','EE','CIVIL'}"></s:combobox></td>
                <td><s:radio name="section" label="Section" list="{'A','B'}"/></td></tr>
                <tr><td>

                    <s:select name="fname" label="Faculty name" list="fname"></s:select>

                </td></tr>
            <tr><td><s:combobox name="userid" label="Faculty id" list="userid"></s:combobox></td></tr>
            <tr><td><s:combobox name="subject" label="Subject Name" list="{'Software Engineering','Soft Computing','Computer Graphics','Real Time System','Introduction To Digital Signal Processing','Entreprenaurship Development'}"></s:combobox></td></tr>
                <tr><td><s:select name="sub_code" label="Subject Code" list="{'PCS098','HCS232','WQ1232','PNB342','WQW232','QAZ213'}"></s:select></td></tr>
                <s:checkbox name="theory" label="Theory"></s:checkbox>
                <s:checkbox name="practical" label="Practical"></s:checkbox>

                <tr><td><s:submit value="allocate"/></td><td><s:submit action="reset" value="Reset"/></td></tr>

                </table>
        </s:form>
        <s:property value="msg"/> 



enter code here
Posted
Updated 18-Jan-14 4:07am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900