From taglibs-user-return-1425-apmail-jakarta-taglibs-user-archive=jakarta.apache.org@jakarta.apache.org Tue Oct 23 21:24:22 2001 Return-Path: Delivered-To: apmail-jakarta-taglibs-user-archive@jakarta.apache.org Received: (qmail 1025 invoked by uid 500); 23 Oct 2001 21:24:22 -0000 Mailing-List: contact taglibs-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk Reply-To: taglibs-user@jakarta.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list taglibs-user@jakarta.apache.org Received: (qmail 1010 invoked from network); 23 Oct 2001 21:24:22 -0000 Date: Tue, 23 Oct 2001 17:24:03 -0400 (EDT) From: Shawn Bayern X-Sender: bayern@precision To: taglibs-user@jakarta.apache.org Subject: Re: jsptl forEach and break In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N On Tue, 23 Oct 2001 sappling@automatedlogic.com wrote: > For the jsptl iterator tags (such as forEach), how can you break out > of a loop early? I would like the functionality you get in Java with > "break" or "continue" statements, but don't see how to do this > without scripting code. Are new tags required for this? New tags would be required for this, but they are not implementable in JSP 1.2 and have thus are not planned for JSPTL 1.0. The problem is how a tag would signal the completion of a loop and cause the loop to terminate immediately. could be implemented merely as a 'signal' to the containing tag to halt iteration after the current round of iteration, but this would not be a true break and would be confusing because of its differences with Java's 'break' keyword. could be implemented better if it threw an exception meant to be caught using JSP 1.2's TryCatchFinally interface, but the implementation would still not be fully operable when custom tags were involved. In a situation like the handler for would, if it implemented TryCatchFinally, need to know to re-throw the exception that the inner tag throws. If it didn't, then 's message would be lost and it would have no effect. A tag that we couldn't guarantee to work wouldn't be much of a tag! is even more problematic, since the TryCatchFinally implementation would be completely untenable: once an exception is caught by doCatch(), there is no mechanism to "restart" the tag. Thus, and are not planned as JSPTL tags, at least not in JSPTL 1.0. You can emulate their behavior with proper structuring of tags. While more verbose, this latter usage is more closely in line with what's seen as a more typical JSP pattern: JSP, being used mostly for presentation, needs less intricate control flow than the Java language itself provides. Shawn Bayern JSPTL reference-implementation lead