
How to access records from database and how to display it on view page, with the help of hibernate?

Hi Friends, With the help of this code you can access data from database and how to display on view page it
Action class
package net.roseindia.action;
import java.util.List;
import net.roseindia.Model.AddInformation;
import net.roseindia.dao.InformationDAO;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
public class InformationAction extends ActionSupport implements ModelDriven {
private AddInformation obAddInfo;
private List infoList;
private int id1;
private InformationDAO obDao = new InformationDAO();
@Override
public String execute() throws Exception {
this.infoList = obDao.list1();
return SUCCESS;
}
}
Mapping file (struts.xml)
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="false" />
<package name="default" namespace="/" extends="struts-default">
<action name="index" class="net.roseindia.action.InformationAction">
<result name="input">AddInforForm.jsp</result>
<result name="success">AddInforForm.jsp</result>
</action>
</package>
</struts>
View page :
<%@taglib uri="/struts-tags" prefix="s"%>
<%@taglib uri="/struts-dojo-tags" prefix="sx"%>
<html>
<head>
<title>Information data </title>
<s:head/>
</head>
<body>
<table border="1">
<caption style="color: green;">Information Added by user</caption>
<tr><th>First Name</th>
<th>Last Name</th>
<th> Gender</th>
<th>Age</th>
<th>Address</th>
<th>Delete</th>
</tr>
<s:iterator value="infoList" var="obAddInfo" >
<tr>
<td><s:property value="firstname"/> </td>
<td><s:property value="lastname"/></td>
<td><s:property value="gender"/></td>
<td><s:property value="age"/></td>
<td><s:property value="address"/></td>
</tr>
</s:iterator>
</table>
</body>
</html>
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.