Joseph Ottinger wrote: > Troy, I'd suggest you not use the JSTL SQL tags, ever, because that embeds > activity into your JSP that really, desperately shouldn't be there. It's > one > thing to do so in a hacked-together app that has a short lifecycle or is > understandably and vibrantly underarchitected, but to do so in a production > application is... a scary thought. > > SQL tags are the sort of thing I'd really hoped the JSTL would have > avoided.
This is an interesting subject with more than one side to it. For some pros and cons with both sides, see a discussion about this very subject that took place on the Taglibs-User mailing list earlier this year: <http://marc.theaimsgroup.com/?t=102348721000002&r=1&w=2> Hans > >> From: "Campano, Troy" <[EMAIL PROTECTED]> >> Reply-To: A mailing list about Java Server Pages specification and >> reference <[EMAIL PROTECTED]> >> To: [EMAIL PROTECTED] >> Subject: JSTL and Connection Pooling >> Date: Mon, 7 Oct 2002 15:55:11 -0400 >> >> Hello, >> I am having a problem trying to figure out JSTL with connection pooling. >> I am using Tomcat. I understand that <sql:setDataSource> can't handle >> connection pooling. >> >> >> So I create a datasource the way I always do without JSTL (using >> JNDI). >> I'm having a problem passing that connection to <sql:query> >> I don't know how to use variables in the tags. >> >> My datasource is called 'ds', but I don't know how to use it with >> sql:query. >> >> pageScope.ds doesn't work. >> >> I'm a complete JSTL newbie and totally confused. >> >> >> Does anyone have any ideas? >> >> Below is the code >> >> >> thank you for the help! >> >> >> Troy Campano >> >> >> ------------------------- CODE HERE >> ----------------------------------------- >> >> >> <%@ page contentType="text/html; charset=iso-8859-1" >> language="java" >> import="java.sql.*,javax.sql.*,oracle.jdbc.pool.*,javax.naming.*,java.io.*" >> >> %> >> >> <%@ taglib prefix="mt" >> uri="http://jakarta.apache.org/taglibs/mailer-1.0 >> <http://jakarta.apache.org/taglibs/mailer-1.0> " %> >> <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core >> <http://java.sun.com/jstl/core> " %> >> <%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql >> <http://java.sun.com/jstl/sql> " %> >> Step 1: Starting Page<br> >> <br> >> Step 2: Creating a list of groups to get the report >> >> >> >> <% >> Connection conn = null; >> try >> { >> //************************************************************************** >> >> *********************** >> // Request Connection from Connection Pool >> //************************************************************************** >> >> *********************** >> Context initContext = new InitialContext(); >> Context envContext = (Context) initContext.lookup("java:/comp/env"); >> DataSource ds = (DataSource) envContext.lookup("jdbc/ReportManagerPool"); >> conn = ds.getConnection(); >> //************************************************************************** >> >> *********************** >> %> >> >> >> >> >> >> <sql:query dataSource="${pageScope.ds}" var="myresultset" >> sql="SELECT table_name FROM all_tables" /> >> >> >> >> >> <% >> } >> catch(SQLException e) >> { >> throw new SQLException(e.getMessage()); >> } >> >> finally >> { >> if (conn != null) >> { >> try >> { >> conn.close(); >> } >> catch (SQLException e) >> { >> // Nothing coherent to do here. >> // Pray nothing else goes wrong. >> e.printStackTrace(); >> } >> } >> } >> %> >> >> =========================================================================== >> >> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff >> JSP-INTEREST". >> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST >> DIGEST". >> Some relevant FAQs on JSP/Servlets can be found at: >> >> http://archives.java.sun.com/jsp-interest.html >> http://java.sun.com/products/jsp/faq.html >> http://www.esperanto.org.nz/jsp/jspfaq.jsp >> http://www.jguru.com/faq/index.jsp >> http://www.jspinsider.com > > > > ----------------------------------------------- > Joseph B. Ottinger [EMAIL PROTECTED] > http://enigmastation.com IT Consultant > > _________________________________________________________________ > MSN Photos is the easiest way to share and print your photos: > http://photos.msn.com/support/worldwide.aspx > > =========================================================================== > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff > JSP-INTEREST". > For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST > DIGEST". > Some relevant FAQs on JSP/Servlets can be found at: > > http://archives.java.sun.com/jsp-interest.html > http://java.sun.com/products/jsp/faq.html > http://www.esperanto.org.nz/jsp/jspfaq.jsp > http://www.jguru.com/faq/index.jsp > http://www.jspinsider.com > -- Hans Bergsten [EMAIL PROTECTED] Gefion Software http://www.gefionsoftware.com JavaServer Pages http://TheJSPBook.com =========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant FAQs on JSP/Servlets can be found at: http://archives.java.sun.com/jsp-interest.html http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.jsp http://www.jguru.com/faq/index.jsp http://www.jspinsider.com