wood burning stoves 2.0*
The moose likes Servlets and the fly likes using drop down list Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "using drop down list" Watch "using drop down list" New topic
Author

using drop down list

Shumaiza Manzoor
Greenhorn

Joined: Sep 03, 2001
Posts: 6
hi all,
please tell me how to use drop down list in servlets, as i write a code in html, but it is a static list, i gave 4 or 5 elements and it displays, but i want to list that displays data from data base field.
i want that,when i insert data in database column the data automatically be viewed in that list.
please help.
tahnx.
Dharmesh Chheda
Ranch Hand

Joined: May 08, 2001
Posts: 204
Hello Shumaiza
i hope this code solves your problem
Assuming that you got the resultset
out.println("<html><body>");
out.println("<table>");
if(resultset.next()==false)
{
response.sendRedirect("somepage");
}
else
{
out.println("<select name=\"Location\">");
out.println("<option value=\" "+resultset.getString(1)+"\">+resultset.getString(1)+"</option>");
while(rest.next())
{
out.println("<option value=\" "+resultset.getString(1)+"\">+resultset.getString(1)+"</option>");
}
out.println("</select>");
}
out.println("</body></html>");
------------------
IBM Certified WebSphere Application Server V3.5 Specialist
[This message has been edited by Dharmesh Chheda (edited September 06, 2001).]


regards,<br />Dharmesh Chheda
 
jQuery in Action, 2nd edition
 
subject: using drop down list
 
Similar Threads
Expandable h:selectOneMenu
ValueChangeListeners in DataTable
JComboBox: JList Wider Than Renderer
Drop-down: How can I make the list bigger than the drop down
How to retrieve data from database when ever select in drop down list?