Class QueryTagSupport
- java.lang.Object
-
- javax.servlet.jsp.tagext.TagSupport
-
- javax.servlet.jsp.tagext.BodyTagSupport
-
- org.apache.taglibs.standard.tag.common.sql.QueryTagSupport
-
- All Implemented Interfaces:
java.io.Serializable,SQLExecutionTag,javax.servlet.jsp.tagext.BodyTag,javax.servlet.jsp.tagext.IterationTag,javax.servlet.jsp.tagext.JspTag,javax.servlet.jsp.tagext.Tag,javax.servlet.jsp.tagext.TryCatchFinally
public abstract class QueryTagSupport extends javax.servlet.jsp.tagext.BodyTagSupport implements javax.servlet.jsp.tagext.TryCatchFinally, SQLExecutionTag
Tag handler for <Query> in JSTL.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.sql.Connectionconnprotected booleandataSourceSpecifiedprivate booleanisPartOfTransactionprotected intmaxRowsprotected booleanmaxRowsSpecifiedprivate java.util.Listparametersprotected java.lang.ObjectrawDataSourceprivate intscopeprotected java.lang.Stringsqlprotected intstartRowprivate java.lang.Stringvar
-
Constructor Summary
Constructors Constructor Description QueryTagSupport()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSQLParameter(java.lang.Object o)Called by nested parameter elements to add PreparedStatement parameter values.voiddoCatch(java.lang.Throwable t)Just rethrows the Throwable.intdoEndTag()Execute the SQL statement, set either through thesqlattribute or as the body, and save the result as a variable named by thevarattribute in the scope specified by thescopeattribute, as an object that implements the Result interface.voiddoFinally()Close theConnection, unless this action is used as part of a transaction.intdoStartTag()Prepares for execution by setting the initial state, such as getting theConnectionprivate java.sql.ConnectiongetConnection()private voidinit()private voidsetParameters(java.sql.PreparedStatement ps, java.util.List parameters)voidsetScope(java.lang.String scopeName)Setter method for the scope of the variable to hold the result.voidsetVar(java.lang.String var)Setter method for the name of the variable to hold the result.-
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doAfterBody, doInitBody, getBodyContent, getPreviousOut, release, setBodyContent
-
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue
-
-
-
-
Field Detail
-
var
private java.lang.String var
-
scope
private int scope
-
rawDataSource
protected java.lang.Object rawDataSource
-
dataSourceSpecified
protected boolean dataSourceSpecified
-
sql
protected java.lang.String sql
-
maxRows
protected int maxRows
-
maxRowsSpecified
protected boolean maxRowsSpecified
-
startRow
protected int startRow
-
conn
private java.sql.Connection conn
-
parameters
private java.util.List parameters
-
isPartOfTransaction
private boolean isPartOfTransaction
-
-
Method Detail
-
init
private void init()
-
setVar
public void setVar(java.lang.String var)
Setter method for the name of the variable to hold the result.
-
setScope
public void setScope(java.lang.String scopeName)
Setter method for the scope of the variable to hold the result.
-
addSQLParameter
public void addSQLParameter(java.lang.Object o)
Called by nested parameter elements to add PreparedStatement parameter values.- Specified by:
addSQLParameterin interfaceSQLExecutionTag- Parameters:
o- thePreparedStatementparameter value
-
doStartTag
public int doStartTag() throws javax.servlet.jsp.JspExceptionPrepares for execution by setting the initial state, such as getting theConnection- Specified by:
doStartTagin interfacejavax.servlet.jsp.tagext.Tag- Overrides:
doStartTagin classjavax.servlet.jsp.tagext.BodyTagSupport- Throws:
javax.servlet.jsp.JspException
-
doEndTag
public int doEndTag() throws javax.servlet.jsp.JspExceptionExecute the SQL statement, set either through the
sqlattribute or as the body, and save the result as a variable named by thevarattribute in the scope specified by thescopeattribute, as an object that implements the Result interface.The connection used to execute the statement comes either from the
DataSourcespecified by thedataSourceattribute, provided by a parent action element, or is retrieved from a JSP scope attribute namedjavax.servlet.jstl.sql.dataSource.- Specified by:
doEndTagin interfacejavax.servlet.jsp.tagext.Tag- Overrides:
doEndTagin classjavax.servlet.jsp.tagext.BodyTagSupport- Throws:
javax.servlet.jsp.JspException
-
doCatch
public void doCatch(java.lang.Throwable t) throws java.lang.ThrowableJust rethrows the Throwable.- Specified by:
doCatchin interfacejavax.servlet.jsp.tagext.TryCatchFinally- Throws:
java.lang.Throwable
-
doFinally
public void doFinally()
Close theConnection, unless this action is used as part of a transaction.- Specified by:
doFinallyin interfacejavax.servlet.jsp.tagext.TryCatchFinally
-
getConnection
private java.sql.Connection getConnection() throws javax.servlet.jsp.JspException, java.sql.SQLException- Throws:
javax.servlet.jsp.JspExceptionjava.sql.SQLException
-
setParameters
private void setParameters(java.sql.PreparedStatement ps, java.util.List parameters) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
-