Hello everyone,
I am able to retrieve database values in my drop down box but not in the manner I want.
1. My employee.jsp is as follows:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<s:form action="AddStudent">
<table border="1" width="80%">
<tr>
<td><s:textfield name="Id" id="Id" value="%{SautoId}" key="SId"/></td>
</tr>
<tr>
<td><s:textfield name="name" id="name" key="SName"/></td></tr>
<tr>
<td><s:textfield name="course" id="course" key="Course" /></td>
<s:select name="DId" value="%{DId}" list="result2"
listkey="DId" label="Designation" >
</s:select>
</tr>
<tr>
<td><s:submit value="ADD"align="center" /></td>
</tr>
</table>
<s:a href="Display.jsp">DISPLAY PAGE</s:a>
</s:form>
</body>
</html>
2. I am getting a list with object values like : com.project.model.StudentVO@7a7a30
com.project.model.StudentVO@2a6a65
com.project.model.StudentVO@4bv67 etc... etc... But I get The exact no. of objects that are there in the datatbase
3. My problem is I am not getting the desired values that are in the database like DES001,DES002,DES003 ....etc...etc...
4. My Action class snippet is as follows :
public String cmbPopulate()
{
IntfStudentBO desgObj = new StudentBO();
result2= desgObj.cmboDid(student1);
if(result2!=null)
{
return SUCCESS;
}
else
{
return ERROR;
}
}
5.My business class snippet :
public List<StudentVO> cmboDid(StudentVO student1) {
List<StudentVO> result= new ArrayList<StudentVO>();
IntfStudentDAO studentDAO = new StudentDAO();
result = studentDAO.cmboDid(student1);
return result;
}
6. My DAO class snippet
public List<StudentVO> cmboDid(StudentVO student1) {
try {
DBConnection dbConnection = new DBConnection();
System.out.println("DATABASE CONNECTED");
try
{
String str= "select D_Id from designation";
String des="";
PreparedStatement ps = dbConnection.getConn().prepareStatement(str);
ResultSet rs =null;
rs=ps.executeQuery();
StudentVO d1;
while (rs.next()) {
d1=new StudentVO();
d1.setDId(rs.getString(1));
des=d1.getDId();
System.out.println("Values of des :"+des);
Slist.add(d1);
}
}
finally{
dbConnection.closeConnection();
}
} catch (SQLException e) {
//TODO Auto-generated catch block
e.printStackTrace();
} catch (NamingException e) {
//TODO Auto-generated catch block
e.printStackTrace();
}
return Slist;
}
Thanks in advance.
Regards,
Piyush N.Sah