aspose file tools*
The moose likes Struts and the fly likes struts2:Displaying dtatbase values in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts2:Displaying dtatbase values in jsp" Watch "struts2:Displaying dtatbase values in jsp" New topic
Author

struts2:Displaying dtatbase values in jsp

govind rajulu
Greenhorn

Joined: Jun 07, 2008
Posts: 3
hi All,
iam getting problems in displaying values from db in jsp.
where i have provided the following information
i am calling the methods in the follwing way

Actionclass->Daoclass(where i am provinding the db logic)
Daoclass:
public List getAllUsers(User user)throws Exception{
users=new ArrayList();
user=new User();
boolean val=false;
String sqlQuery="select * from user";
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery(sqlQuery);
while(rs.next()){
user.setFirstName(rs.getString("firstname"));
user.setLastName(rs.getString("lastname"));
user.setUserName(rs.getString("username"));
user.setPassword1(rs.getString("password"));
user.setEmailId(rs.getString("emailid"));
user.setCountry(rs.getString("country"));
user.setState(rs.getString("state"));
user.setPinCode(rs.getInt("pincode"));
user.setVCode(rs.getString("v_code"));
val=users.add(user);

}
if(val){
return users;
}else{
return null;
}

}





jsp:
<table cellspacing="5" cellpadding="2" width="600">
<tr bgcolor="#f0edd9">
<td>firstName</td>
<td>lastName</td>
<td>userName</td>
<td>password</td>
<td>EmailId</td>
<td>Country</td>
<td>State</td>
<td>City</td>
<td>Pincode</td>
<td>VCode</td>
</tr>
<s:iterator value="users" status="user">
<s:iterator value="users[#user.index]">
<tr>
<td><s roperty value="%{firstName}"/></td>
<td><s roperty value="%{lastName}"/></td>
<td><s roperty value="%{userName}"/></td>
<td><s roperty value="%{passowrd}"/></td>
<td><s roperty value="%{emailId}"/></td>
<td><s roperty value="%{country}"/></td>
<td><s roperty value="%{state}"/></td>
<td><s roperty value="%{city}"/></td>
<td><s roperty value="%{pincode}"/></td>
<td><s roperty value="%{vcode}"/></td>
</tr>
</s:iterator>
</s:iterator>
</table>
this is my code where i am not getting the values in jsp.but it also not showing any error.

means it is taking the INPUT result type.(means nee some thing more input to get Succecc Result).

But i dont what i need to provide to get the succec result
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts2:Displaying dtatbase values in jsp