Taylor Gautier wrote:
> I fully agree that SQL and CONNECTION tags don't make any sense in a
JSP
> page. Looping, conditional constructs and the like (only for display
> purposes, not for actually coding logic) would be good standard tags.
After spending the past few hours attempting to design a <connection>
tag and
failing miserably, I tend to agree with you; there are just too many
implementation
specific details to come up with a standard API in a <connection> tag.
It is
business logic, and should be in a bean which can be referenced by the
JSP page
through a scripting variable. There may be more hope for a <query> or
<sql> tag.
Here is a preliminary spec:
query
Passes any SQL statement to a JDBC connection created previously
(usually by a
bean).
<query id="queryName" REQUIRED
connection="connectionId" REQUIRED
timedcache="seconds" DEFAULTS to 0
maxrows="number" DEFAULTS to inifinity
>
All JSP parsable statements are resolved into a string. This string
is an SQL
statement
that is passed straight through to the JDBC driver, and is
unintelligible to the
JSP
engine.
A good tag to nest here would be <jsp:include>, which allows the
query to be
stored in
a separate file.
</pdx:query>
id The unique name you assign to this query which gets
stored in a
page scope variable.
connection The JDBC connection from which this query should retrieve
data
(deliberately vague, as more design has to be done)
timedcache Specifies the number of seconds that the query should be
cached on the
server. All future <query> calls with the same parameters and SQL
string within
the given time span and within application scope will access the cached
query
instead of generating a JDBC call.
maxrows Specifies the maximum number of rows you want returned in
the record
set.
example:
<query id="foo" connection="<%=beanMadeConnection%>" timedcache="60"
maxrows="10">
SELECT NAME FROM CUSTOMER
</query>
<table>
<th>Name of customer</th>
<loop query="foo">
<tr><td><field field="name"></td></tr>
</loop>
</table>
would output HTML:
<table>
<th>Name of customer</th>
<tr><td>Name1</td></tr>
<tr><td>Name2</td></tr>
<tr><td>Name3</td></tr>
</table>
> The rule would be: do most if not all JSP applications need these
tags?
>
> For database tags, I think the answer to that question is definitely
NO!
Agreed. Tags that would be useful to all JSP applications could be
considered for
placement in the jsp namespace, such as: <jsp:setData> or <jsp:getData>
(refer to
previous postings in this thread for a proposed "wrapper tags" on jsp
implicit
objects)
Tags that would be useful as a standard, but only for a (significant)
subset of JSP
apps should be in their own namespace, such as: <database:loop> or
<database:field>. This way, the core namespace is not polluted, but a
separate
(shared, and free) namespace is provided for a common set of tags to
developers who
are interested in them.
This argument is analogous to Java packages: core APIs are in the java
package,
like java.lang while specialized APIs are in the javax package, like
javax.sql.
You can ignore javax functionality if you do not need it; similarly, you
can ignore
<database: > tags if you are not interested in database connnectivity
for your JSP
apps.
--
Michael Hu, Paradox Team, Corel Corporation
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html