how to use a list containing the query result with hibernate and display it in jsp
- by kawtousse
hi everyone,
In my servlet I construct the query like the following:
net.sf.hibernate.Session s = null;
net.sf.hibernate.Transaction tx;
try {
s= HibernateUtil.currentSession();
tx=s.beginTransaction();
Query query = s.createQuery("select opcemployees.Nom,opcemployees.Prenom,dailytimesheet.TrackingDate,dailytimesheet.Activity," +
"dailytimesheet.ProjectCode,dailytimesheet.WAName,dailytimesheet.TaskCode," +
"dailytimesheet.TimeSpent,dailytimesheet.PercentTaskComplete from Opcemployees opcemployees,Dailytimesheet dailytimesheet " +
"where opcemployees.Matricule=dailytimesheet.Matricule and dailytimesheet.Etat=3 " +
"group by opcemployees.Nom,opcemployees.Prenom" );
List opdts= query.list();
request.setAttribute("items", opdts);
request.getRequestDispatcher("EspaceValidation.jsp").forward(request, response);
} catch (HibernateException e){ e.printStackTrace();}
But in the jsp I can't display the result correctly. I do the following in JSP:
<table>
<c:forEach items="${items}" var="item">
<tr>
<td>${item}</td>
</tr>
</c:forEach>
</table>
thanks for help.