KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > taglibs > dbtags > statement > QueryTag


1 /*
2  * Copyright 1999,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.taglibs.dbtags.statement;
17
18 import java.sql.SQLException JavaDoc;
19
20 import javax.servlet.jsp.JspTagException JavaDoc;
21 import javax.servlet.jsp.tagext.BodyTagSupport JavaDoc;
22
23 /**
24  * <p>JSP tag query, sets the SQL query for the enclosing statement or
25  * preparedstatement tag. </p>
26  *
27  * <p>JSP Tag Lib Descriptor
28  * <pre>
29  * &lt;name>query&lt;/name>
30  * &lt;tagclass>org.apache.taglibs.dbtags.statement.QueryTag&lt;/tagclass>
31  * &lt;bodycontent>JSP&lt;/bodycontent>
32  * &lt;info>Sets the SQL query for the enclosing statement or
33  * preparedstatement tag.&lt;/info>
34  * </pre>
35  *
36  * @author Morgan Delagrange
37  * @see StatementImplTag
38  * @see org.apache.taglibs.dbtags.preparedstatement.PreparedStatementImplTag
39  */

40
41 public class QueryTag extends BodyTagSupport JavaDoc {
42
43   public int doEndTag() throws JspTagException JavaDoc{
44     try {
45       StatementTag stmtTag =
46       (StatementTag) findAncestorWithClass(this, Class.forName("org.apache.taglibs.dbtags.statement.StatementTag"));
47       stmtTag.setQuery(getBodyContent().getString().trim());
48     } catch (ClassNotFoundException JavaDoc e) {
49       throw new JspTagException JavaDoc(e.toString());
50     } catch (SQLException JavaDoc e) {
51       throw new JspTagException JavaDoc(e.toString());
52     }
53     return EVAL_PAGE;
54   }
55
56 }
57
Popular Tags