This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Grokking Bitcoin and have Kalle Rosenbaum on-line!
See this thread for details.
Win a copy of Grokking Bitcoin this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
  • Carey Brown
  • salvin francis
  • Claude Moore

How to use JSTL instead of scriptlet.This is about JDBC.  RSS feed

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry,my English is pool.I try my best to express my mind....

I use this scriptlet to display some data form SERVLET:
<table border="1" cellspacing="0">
<%ResultSet rset=(ResultSet)request.getAttribute("rset");
<td><%=rset.getString("UserId") %></td>
<td><%=rset.getString("Email") %></td>
<%} %>
How can I use JSTL to instead of this scriptlet?
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSTL does provide a set of SQL tags but many of us consider it a mistake to have created them. JSTL and EL were meant to give JSP developers just enough capability to work with the results of operations performed in the controller and model tiers in order to mark up the pages. No more.

The SQL tags were added for prototyping, testing, and trivial applications.
From the JSTL specs:

Because the SQL tags violate many of the principal reasons for having JSTL and EL in the first place, many of the experienced developers who frequent this forum don't bother with them at all. As a consequence there are very few people who can answer questions about them.

All that being said, if you still want to use them, I suggest dowloading the spec and reading section 10.
[ March 22, 2008: Message edited by: Ben Souther ]
William Turner
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess that I could use
<%@ taglib prefix="sql" uri="" %>
In fact,I have tried it in the afternoon.
Other codes in JSP:
<sql:query var="query" dataSource="${dbsor}">
SELECT UserId,Email FROM UserDetails
<c:forEach var="row" items="${query.rows}">
<td><c:out value="${row.CustId}"/></td>
<td><c:out value="${row.Email}"/></td>

and some codes in SERVLET:
RequestDispatcher view=request.getRequestDispatcher("test.jsp");
view.forward(request, response);

The "pool" is a Connection Pooling Bean.
But it dose not work,log is:
javax.servlet.ServletException: javax.servlet.jsp.JspException: 'dataSource' is neither a String nor a javax.sql.DataSource

DataSource error?
I can't take it! You are too smart for me! Here is the tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!