• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

struts2:Displaying dtatbase values in jsp

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
No. No. No. No. Changed my mind. Wanna come down. To see this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic