-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Quering and Display set
PostPosted: Thu Apr 13, 2006 3:45 pm 
Newbie

Joined: Tue Apr 11, 2006 4:20 pm
Posts: 14
I have an application, I have successfully persisted about 100 objects into a MySQL 5.0 database...

I want to write a servlet that will query the database and display the results..

I have read my book "Hibernate Quickly" (the book store didn't have Hibernate In Action). They talk about how to perform queries but now how to display them back. I have searched google and the forum and haven't found a way to display my results back... so far I have the following


a function called retrieve. inside retrieve I

Code:
// Build and configure the session factory
SessionFactory sf = HibernateFactory.buildSessionFactory();

// Create and open session
Session session = sf.openSession();

Query query = session.createQuery("from TaskForm");
List results = query.list();


How do I take results and display it???? Please forgive my ignorance.

_________________
Cheers,
Ken


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 17, 2006 5:12 pm 
Beginner
Beginner

Joined: Thu Aug 19, 2004 2:33 pm
Posts: 30
Location: CA, USA
See the javadoc for HttpServletResponse at http://java.sun.com/j2ee/sdk_1.3/techdo ... getWriter()

You can use the getWriter() (or getOutputStream()) methods and then println's on the Writer to write out the results.

However, typically people put the results in the request (request.setAttribute()) and then loop through them in a JSP page. Using JSTL EL in the JSP page:

Code:
  <ul>
    <c:forEach var="user" items="${users}">
       <li>${user.firstName} ${user.lastName}
    </c:forEach>
  </ul>
 


Is that what you're asking for?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 18, 2006 10:36 am 
Newbie

Joined: Tue Apr 11, 2006 4:20 pm
Posts: 14
I took your advice and saved it to the http session. however, instead of writing some jsp loop, i used the display tag library. just pointed the display tag to the javabean and it works like a charm.

_________________
Cheers,
Ken


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.