dynamically load drop-down in jsp
i am new to jsp and am trying to utilize a class of mine within a jsp. i have a method that collects the metaData from a database. I return a vector from my method containing all the table names that are within the database. I want to put those table names in a drop-down list within a jsp. Can anyone help me please?
# 2
<ur dropdown come here>
<%
Vector Test = new Vector();
Test = callfunctioncontainsdatabasevalues();
for(int i=0;i<Test.size();i++)
{
%>
<option><%=Test.get(i)%></option>
<%}%>
%>
# 5
<ur dropdown come here>
<%
Vector Test = new Vector();
Test = callfunctioncontainsdatabasevalues();
for(int i=0;i<Test.size();i++)
{
%>
<option><%=Test.get(i)%></option>
<%}%>
%>
I found this useful snippet somwehere in this forum.
# 6
<?xml version="1.0" encoding="UTF-8" ?>
<%@ page contentType="text/html" %>
<%@ page pageEncoding="UTF-8" %>
<%@ page import="dataPack.*" %>
<%@ page import="java.util.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>York County Archives</title>
</head>
<body>
<% ConnectDB drop = new ConnectDB();
// int size;
Vector names = new Vector();
names = drop.getTableInfo();
//size = names.size();%>
<h1>Start Page for searching archives</h1>
<form method="post" action="extractData.jsp">
Please choose a table to search from drop-down:
<select name="userList" size="1" width="25">
<% for(int i=0; i<names.size(); i++){
%>
<option value='<%= names.get(i) %>' ><%=names.get(i) %></option>
<% } %>
</select> <input type="submit" name="submit" value=">> Next >>" />
<h3>OR...</h3>
<!--
Enter a table to search for:
<input type="text" name="tableInquiry" size="15" />
<input type="submit" name="submit" value=">> Next >>" />
<h3>OR...</h3>-->
<input type="submit" name="submit" value="View complete grid" />
</form>
</body>
</html>