tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: Down the rabbit hole with JDBC
Date Thu, 31 Jul 2008 14:26:49 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Matt,

Just a note: as you seem to be just getting started with everything,
might I make the bold recommendation that you avoid doing any database
work from JSPs?

Databases are notoriously finicky when it comes to resource management
(cleaning up after aborted results, closing various resources, etc.),
and JSPs totally suck when trying to provide clean try/catches and stuff
like that.

My (unsolicited) advice to you would be to avoid any data transfer or
business logic inside any of the JSPs that you write.

Granted, you are following a tutorial just as a proof-of-concept to get
everything working, but often folks find that the path or least
resistance is to just modify examples to fit their needs.

Good luck,
- -chris

Matt Burkhardt wrote:
| <%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
| <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
|
| <sql:query var="rs" dataSource="jdbc/TestDB">
| select id, foo, bar from testdata
| </sql:query>
|
| <html>
|   <head>
|     <title>DB Test</title>
|   </head>
|   <body>
|
|   <h2>Results</h2>
|
| <c:forEach var="row" items="${rs.rows}">
|     Foo ${row.foo}<br/>
|     Bar ${row.bar}<br/>
| </c:forEach>
|
|   </body>
| </html>

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkiRy6kACgkQ9CaO5/Lv0PCFvQCfQ+/eYn9WVMm54dG1iETQq7O1
tisAoLUs5vrykKb0w6PfcYffEV4oKqkS
=lpYH
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message