Skip to content
Advertisement

How to display in JSP a list obtained from Hibernate query

I am creating an struts hibernate application. I have obtained a list using hibernate query and passed it in action class. But I don’t know how to display it in JSP.

I have successfully getting the list on the basis of query. Now I want to display this list in JSP.

I have posted struts.xml and the JSP for showing result also. Kindly check. But in JSP nothing is showing up. I am using s:iterate to show the list. But no luck. Even I have tried printing simple text under s:iterate, just for testing. But it is also not showing up.

POJO class:

JavaScript

Action Class:

JavaScript

Hibernate class:

JavaScript

This is my struts.xml in which all actions are defined.For now the action is ByDate.

struts.xml:

JavaScript

This is my JSP for showing list

iterate.jsp:

JavaScript

I have successfully getting the list on the basis of query. Now I want to display this list in JSP.

Advertisement

Answer

Use iterator tag:

Iterator will iterate over a value. An iterable value can be any of: java.util.Collection, java.util.Iterator, java.util.Enumeration, java.util.Map, or an array.

The code:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement