</txt2html>
<txt2html todir="${tomcat.build}/webapps/examples/jsp/jsp2/el">
+ <fileset dir="webapps/examples/WEB-INF/classes/examples">
+ <include name="ValuesTag.java"/>
+ </fileset>
+ <fileset dir="webapps/examples/WEB-INF/classes/jsp2/examples">
+ <include name="ValuesBean.java"/>
+ </fileset>
<fileset dir="webapps/examples/WEB-INF/classes/jsp2/examples/el">
<include name="Functions.java"/>
</fileset>
--- /dev/null
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package examples;
+
+import javax.servlet.jsp.*;
+import javax.servlet.jsp.tagext.*;
+
+import java.io.*;
+
+/**
+ * Accept and display a value.
+ */
+public class ValuesTag extends TagSupport {
+ // Using "-1" as the default value,
+ // in the assumption that it won't be used as the value.
+ // Cannot use null here, because null is an important case
+ // that should be present in the tests.
+ private Object objectValue = "-1";
+ private String stringValue = "-1";
+ private long longValue = -1;
+ private double doubleValue = -1;
+
+ public void setObject(Object objectValue) {
+ this.objectValue = objectValue;
+ }
+
+ public void setString(String stringValue) {
+ this.stringValue = stringValue;
+ }
+
+ public void setLong(long longValue) {
+ this.longValue = longValue;
+ }
+
+ public void setDouble(double doubleValue) {
+ this.doubleValue = doubleValue;
+ }
+
+ public int doEndTag() throws JspException {
+ JspWriter out = pageContext.getOut();
+
+ try {
+ if (!"-1".equals(objectValue)) {
+ out.print(objectValue);
+ } else if (!"-1".equals(stringValue)) {
+ out.print(stringValue);
+ } else if (longValue != -1) {
+ out.print(longValue);
+ } else if (doubleValue != -1) {
+ out.print(doubleValue);
+ } else {
+ out.print("-1");
+ }
+ } catch (IOException ex) {
+ throw new JspTagException("IOException: " + ex.toString(), ex);
+ }
+ return super.doEndTag();
+ }
+}
--- /dev/null
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+
+package jsp2.examples;
+
+/**
+ * Accept and display a value.
+ */
+public class ValuesBean {
+ private String string;
+ private double doubleValue;
+ private long longValue;
+
+ public ValuesBean() {
+ }
+
+ public String getString() {
+ return this.string;
+ }
+
+ public void setString(String string) {
+ this.string = string;
+ }
+
+ public double getDouble() {
+ return doubleValue;
+ }
+
+ public void setDouble(double doubleValue) {
+ this.doubleValue = doubleValue;
+ }
+
+ public long getLong() {
+ return longValue;
+ }
+
+ public void setLong(long longValue) {
+ this.longValue = longValue;
+ }
+}
<required>false</required>
</attribute>
</tag>
-
+
+ <!-- Another simple Tag -->
+ <!-- values tag -->
+ <tag>
+ <name>values</name>
+ <tag-class>examples.ValuesTag</tag-class>
+ <body-content>empty</body-content>
+ <description>
+ Accept and return values of different types. This tag is used
+ to illustrate type coercions.
+ </description>
+ <attribute>
+ <name>object</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <type>java.lang.Object</type>
+ </attribute>
+ <attribute>
+ <name>string</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <name>long</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <type>long</type>
+ </attribute>
+ <attribute>
+ <name>double</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <type>double</type>
+ </attribute>
+ </tag>
</taglib>
</tr>
<tr valign=TOP>
+<td>Composite Expressions</td>
+<td valign=TOP width="30%"><a href="jsp2/el/composite.jsp"><img src="images/execute.gif" hspace=4 border=0 align=top></a><a href="jsp2/el/composite.jsp">Execute</a></td>
+
+<td width="30%"><a href="jsp2/el/composite.html"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP></a><a href="jsp2/el/composite.html">Source</a></td>
+</tr>
+
+
+<tr valign=TOP>
<td><br><b>SimpleTag Handlers and JSP Fragments</b></td>
</tr>
--- /dev/null
+<html>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<head>
+<title>View Source Code</title>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+</head>
+
+<body bgcolor="#FFFFFF">
+<p><font color="#0000FF"><a href="composite.jsp"><img src="../../images/execute.gif" align="right" border="0"></a><a href="../../index.html"><img src="../../images/return.gif" width="24" height="24" align="right" border="0"></a></font></p>
+
+<h3><a href="composite.jsp.html">Source Code for composite.jsp</a></h3>
+<h3><a href="ValuesTag.java.html">Source Code for ValuesTag.java</a></h3>
+<h3><a href="ValuesBean.java.html">Source Code for ValuesBean.java</a></h3>
+
+</body>
+</html>
--- /dev/null
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<%@ taglib prefix="my" uri="http://tomcat.apache.org/example-taglib" %>
+
+<html>
+ <head>
+ <title>JSP 2.0 Expression Language - Composite Expressions</title>
+ </head>
+ <body>
+ <h1>JSP 2.0 Expression Language - Composite Expressions</h1>
+ <hr>
+ This example illustrates EL composite expressions. Composite expressions
+ are formed by grouping together multiple EL expressions. Each of them is
+ evaluated from left to right, coerced to String, all those strings are
+ concatenated, and the result is coerced to the expected type.
+
+ <jsp:useBean id="values" class="jsp2.examples.ValuesBean" />
+
+ <blockquote>
+ <code>
+ <table border="1">
+ <thead>
+ <td><b>EL Expression</b></td>
+ <td><b>Type</b></td>
+ <td><b>Result</b></td>
+ </thead>
+ <tr>
+ <td>\${'hello'} wo\${'rld'}</td>
+ <td>String</td>
+ <td><jsp:setProperty name="values" property="string" value="${'hello'} wo${'rld'}"/>${values.string}</td>
+ </tr>
+ <tr>
+ <td>\${'hello'} wo\${'rld'}</td>
+ <td>String</td>
+ <td><my:values string="${'hello'} wo${'rld'}"/></td>
+ </tr>
+ <tr>
+ <td>\${1+2}.\${220}</td>
+ <td>Double</td>
+ <td><jsp:setProperty name="values" property="double" value="${1+2}.${220}"/>${values.double}</td>
+ </tr>
+ <tr>
+ <td>\${1+2}.\${220}</td>
+ <td>Double</td>
+ <td><my:values double="${1+2}.${220}"/></td>
+ </tr>
+ <tr>
+ <td>000\${1}\${7}</td>
+ <td>Long</td>
+ <td><jsp:setProperty name="values" property="long" value="000${1}${7}"/>${values.long}</td>
+ </tr>
+ <tr>
+ <td>000\${1}\${7}</td>
+ <td>Long</td>
+ <td><my:values long="000${1}${7}"/></td>
+ </tr>
+ <!--
+ Undefined values are to be coerced to String, to be "",
+ https://issues.apache.org/bugzilla/show_bug.cgi?id=47413
+ -->
+ <tr>
+ <td>\${undefinedFoo}hello world\${undefinedBar}</td>
+ <td>String</td>
+ <td><jsp:setProperty name="values" property="string" value="${undefinedFoo}hello world${undefinedBar}"/>${values.string}</td>
+ </tr>
+ <tr>
+ <td>\${undefinedFoo}hello world\${undefinedBar}</td>
+ <td>String</td>
+ <td><my:values string="${undefinedFoo}hello world${undefinedBar}"/></td>
+ </tr>
+ <tr>
+ <td>\${undefinedFoo}\${undefinedBar}</td>
+ <td>Double</td>
+ <td><jsp:setProperty name="values" property="double" value="${undefinedFoo}${undefinedBar}"/>${values.double}</td>
+ </tr>
+ <tr>
+ <td>\${undefinedFoo}\${undefinedBar}</td>
+ <td>Double</td>
+ <td><my:values double="${undefinedFoo}${undefinedBar}"/></td>
+ </tr>
+ <tr>
+ <td>\${undefinedFoo}\${undefinedBar}</td>
+ <td>Long</td>
+ <td><jsp:setProperty name="values" property="long" value="${undefinedFoo}${undefinedBar}"/>${values.long}</td>
+ </tr>
+ <tr>
+ <td>\${undefinedFoo}\${undefinedBar}</td>
+ <td>Long</td>
+ <td><my:values long="${undefinedFoo}${undefinedBar}"/></td>
+ </tr>
+ </table>
+ </code>
+ </blockquote>
+ </body>
+</html>
+