Author: markt Date: Mon Apr 29 13:24:36 2013 New Revision: 1477051 URL: http://svn.apache.org/r1477051 Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=54888 Support a csv list with the ForEach tag plugin Based on a patch provided by Sheldon Shao
Added: tomcat/trunk/test/webapp-3.0/bug5nnnn/bug54888.jsp (with props) Modified: tomcat/trunk/java/org/apache/jasper/tagplugins/jstl/core/ForEach.java tomcat/trunk/test/org/apache/jasper/tagplugins/jstl/core/TestForEach.java Modified: tomcat/trunk/java/org/apache/jasper/tagplugins/jstl/core/ForEach.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/tagplugins/jstl/core/ForEach.java?rev=1477051&r1=1477050&r2=1477051&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/jasper/tagplugins/jstl/core/ForEach.java (original) +++ tomcat/trunk/java/org/apache/jasper/tagplugins/jstl/core/ForEach.java Mon Apr 29 13:24:36 2013 @@ -155,6 +155,10 @@ public final class ForEach implements Ta ctxt.generateJavaSource("else if (" + itemsV + " instanceof Map)"); ctxt.generateJavaSource(iterV + "=((Map)" + itemsV + ").entrySet().iterator();"); + // String + ctxt.generateJavaSource("else if (" + itemsV + " instanceof String)"); + ctxt.generateJavaSource(iterV + "=toIterator(new StringTokenizer((String)" + itemsV + ", \",\"));"); + // Not null ctxt.generateJavaSource("if (" + iterV + " != null) {"); Modified: tomcat/trunk/test/org/apache/jasper/tagplugins/jstl/core/TestForEach.java URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/jasper/tagplugins/jstl/core/TestForEach.java?rev=1477051&r1=1477050&r2=1477051&view=diff ============================================================================== --- tomcat/trunk/test/org/apache/jasper/tagplugins/jstl/core/TestForEach.java (original) +++ tomcat/trunk/test/org/apache/jasper/tagplugins/jstl/core/TestForEach.java Mon Apr 29 13:24:36 2013 @@ -39,4 +39,19 @@ public class TestForEach extends Abstrac Assert.assertTrue(body.contains("OK - 2")); Assert.assertFalse(body.contains("FAIL")); } + + @Test + public void testBug54888() throws Exception { + ByteChunk res = new ByteChunk(); + + int rc = getUrl("http://localhost:" + getPort() + + "/test/bug5nnnn/bug54888.jsp", res, null); + + Assert.assertEquals(HttpServletResponse.SC_OK, rc); + + String body = res.toString(); + Assert.assertTrue(body.contains("OK - 1")); + Assert.assertTrue(body.contains("OK - 2")); + Assert.assertTrue(body.contains("OK - 3")); + } } Added: tomcat/trunk/test/webapp-3.0/bug5nnnn/bug54888.jsp URL: http://svn.apache.org/viewvc/tomcat/trunk/test/webapp-3.0/bug5nnnn/bug54888.jsp?rev=1477051&view=auto ============================================================================== --- tomcat/trunk/test/webapp-3.0/bug5nnnn/bug54888.jsp (added) +++ tomcat/trunk/test/webapp-3.0/bug5nnnn/bug54888.jsp Mon Apr 29 13:24:36 2013 @@ -0,0 +1,27 @@ +<%-- + 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. +--%> +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1" session="true" + import="java.io.Reader,java.io.StringReader" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<html> + <body> + <c:forEach items="1,2,3" var="foo"> + <p>OK - ${foo}</p> + </c:forEach> + </body> +</html> \ No newline at end of file Propchange: tomcat/trunk/test/webapp-3.0/bug5nnnn/bug54888.jsp ------------------------------------------------------------------------------ svn:eol-style = native --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org