• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to pass Data from Hibernate query.list to the JSP Page

 
PavanPL KalyanK
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi , Thi is my DAO Layer calling this from Servlet , How can i pas the Obtained Result to the JSP Page??

public List getCustomerList()
{
Session session = null;

try
{
session = HibernateUtil.openSession();
/*
* Build HQL (Hibernate Query Language) query to retrieve a list
* of all the items currently stored by Hibernate.
*/
Query query = session.createQuery("select Customer from com.frontier.hibernate.Customer Customer order by Customer.customerid");
return query.list();

}
 
Omar Al Kababji
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can use a RequestDispatcher and then dispatch the result to the JSP something like this


request.setAttribute("myList", listObtainFromHibernateQuery);
RequestDispatcher dispt = request.getRequestDispatcher("/path2JSP/myjsp.jsp";
dispt.dispatch(request, response);


note that you can use relative or absolute path names ;)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic