• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Result Set display in JSP

 
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not sure if this question were posted
If yes please refer me to the URL
Here is the question
I have a resultset from database, I am forwarding this resultset from a servlet to a jsp to display it
Are there any taglibs i can use to help display the results in a table format
Please help me
Ragu
 
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ragu,
Check out the DBTags tag library over at the Jakarta project - there's a whole bunch of tags in there that might be of use.
As a side-note, there is nothing "wrong" with accessing the database from your web-tier (your JSPs and servlets), but for larger applications I would recommend adopting a layered architecture where you have an abstraction onto your data access/peristence services. Also, take a look at the model 2 web application architecture as it will help acheive a cleaner separation between the classes in your application.
Anyway, take a look at DBTags...
Cheers
Simon
 
Author
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ragu Sivaraman:

Here is the question
I have a resultset from database, I am forwarding this resultset from a servlet to a jsp to display it
Are there any taglibs i can use to help display the results in a table format


Hi Ragu. I'm a commiter over at Jakarta Taglibs and the RI lead for the JSP Standard Tag Library (JSTL). As Simon mentioned, DBTags is a great possibility, but if you're using JSP 1.2, DBTags's functionality is effectively replaced by JSTL. I suggest you take a look at it; like DBTags, the reference implementation is hosted at Jakarta Taglibs:
http://jakarta.apache.org/taglibs/doc/standard-doc/intro.html
One of the advantages of JSTL's support for ResultSet is that it caches the data from a ResultSet object, closes the result set, and returns the corresponding connection to its pool. Since a ResultSet is tied to a Connection, you need to keep the connection open to access data through a ResultSet -- but this can lead to less efficient pooling; JSTL addresses this issue.
Please feel free to let me know if you've got any questions about JSTL (or about the custom Jakarta Taglibs libraries).
 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Saw another tag that could do what you need.
See http://www.dotjonline.com/taglib/grid.jsp
 
Ragu Sivaraman
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you all for a quick and precise reply
This forum really rocks!!!
Now coming back to my question
I actually went thru that path of using DB tags before posting this question
In my case , I am not using JSP to access database. Servlets does most of the work. I wrote an jdbc utility(seperating presentation logic from data accesslogic) and the servlet just utilize it to get the result set..
Once it gets the resultset, the servlet puts the result set on to its httpsession object and do a
RequestDispatcher (ie forwards the http request) to
a jsp (Results.jsp)
Here is where i am lost..
<sql:resultSet id="resultset" class="java.sql.ResultSet" scope = "session">
<tr>
<td><sql:getColumn position="1"/></td>
<td><sql:getColumn position="2"/></td>
<td><sql:getColumn position="3"/>
<sql:wasNull>The Resultset are null</sql:wasNull></td>
</tr>
</sql:resultSet>

Every time i run this JSP i get "The resultset are null". This may be true just due to fact that i dont have any connection to the database at all from the jsp.
So i have to find out an alternative to just iterate the resultset and display it out in a table
format. To do this , are there any iterator tagslib
i can make use of?
Can struts help me to do it? If not are there any samples i can see to learn how its done?

Please let me know
thanks again
Ragu
I may be missing something here. Gurus please guide me
Thanks
Ragu
[ May 08, 2002: Message edited by: Ragu Sivaraman ]
 
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I've been following this thread and have 2 questions:
1o) I've checked the e-mail taglib and it's pretty cool, but, Am I 'violating' the model 2 design pattern doing the e-mail processing in the JSP page? I was planning to process everything in a servlet, having only the presentation performed by the jsp page.
2o.)Can I use this DBTag library if i'm using connection pooling?? any documentation available?
thanks
 
Shawn Bayern
Author
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ragu Sivaraman:
Every time i run this JSP i get "The resultset are null". This may be true just due to fact that i dont have any connection to the database at all from the jsp.


Unfortunately, it's hard to debug this problem from outside.
As a related note, which might help you (though it's not a direct answer to your question), JSTL's API provides the ability to cache a ResultSet and expose it as a JavaBean. This might make debugging your problem more straightforward, since you can handle all processing of your ResultSet in your servlet and then simply expose an in-memory structure to your JSP page.
 
Shawn Bayern
Author
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Andres Gonzalez:
Hi, I've been following this thread and have 2 questions:
1o) I've checked the e-mail taglib and it's pretty cool, but, Am I 'violating' the model 2 design pattern doing the e-mail processing in the JSP page? I was planning to process everything in a servlet, having only the presentation performed by the jsp page.
2o.)Can I use this DBTag library if i'm using connection pooling?? any documentation available?
thanks


1) Interpretation of models is subjective; there's nothing inherently unmaintainable about sending an email from a JSP page. Because you can also do so from a servlet, where you likely have more programmatic control, many people would probably suggest you put the logic there. But if the tag library that you've found or written meets your needs, there's certainly no problem in using it.
2) I believe so, though I'm not up on DBTags's details enough to answer for sure (or to explain how). As I may have mentioned before, DBTags is superceded in many ways by the JSP Standard Tag Library's database support. JSTL provides access to databases in terms of the standard javax.sql.DataSource class, which is easily and often used to provide pooled access to a database.
Hope that helps!
[ May 09, 2002: Message edited by: Shawn Bayern ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic