i think you should try this
public class EmpBean {
public java.util.List dataList(){
ArrayList list=new ArrayList();
try{
Class.forName("driver");
Connection con = DriverManager.getConnection("url", "user", "pwd");
Statement st=con.createStatement();
System.out.println("hiiiii");
ResultSet rs=st.executeQuery("select * from employee");
while(rs.next()){
list.add(rs.getString("name"));
list.add(rs.getString("address"));
list.add(rs.getString("contactNo"));
list.add(rs.getString("email"));
}
System.out.println(rs.getString("contactNo"));
}
catch(Exception e){}
return list;
}
}
Assuming this class working fine and it is returning list with some value
now on your jsp page
<%@page language="java" import="java.util.*" %>
<html>
<body>
<table border="1" width="303">
<tr>
<td width="119"><b>Name</b></td>
</tr>
<%
ArrayList list;
EmpBean emp = new EmpBean();
list = emp.dataList();
ArrayList li = (ArrayList) li.get(0);
%>
<tr>
<select name="" id="" style="width: 150px;"">
<option value="-1"><%=li.get(1)%></option>
</select>
</tr>
</table>
</body>
</html>
just check this code…it might happen that values fetched may be wrong here just check the values by changing list indexing and also if you can surround the whole scriptlets thing with try catch so that if exception occurs it will be easy to find bug…good luck and don’t worry if it doesn’t works i will give you sample code for sure i am using this code my project
3
solved how to display values in jsp through java class [closed]