how to use a list containing the query result with hibernate and display it in jsp
Posted
by kawtousse
on Stack Overflow
See other posts from Stack Overflow
or by kawtousse
Published on 2010-06-02T09:45:19Z
Indexed on
2010/06/02
12:04 UTC
Read the original article
Hit count: 255
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.
© Stack Overflow or respective owner