No, the first solution should't work:
<% break; %>
<% case 2: %>
Will be tranformed to something like:
break;
out.print("\n");
case 2:
That doesn't look like valid java syntax to me.
These will work:
<% break;
case 2:
%>
<% break;
%><% case 2: %>
However, I prefer the JSTL solution.
(But can't use it, a we still use JSP 1.0)
> -----Original Message-----
> From: David Rees [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, February 24, 2004 8:55 AM
> To: Tomcat Users List
> Subject: Re: What's the problem with Tomcat 4.1.29 and Switch?
>
>
> If you want to use a switch, this should work:
>
> <% switch (day) {
> case 1: %>
> <font color="blue" size="+1">Sunday</font>
> <% break; %>
> <% case 2: %>
> <font color="blue" size="+1">Monday</font>
> <% break; %>
> <% default: %>
> <font color="blue" size="+1">No day</font>
> <% break; } %>
>
> But really, the best way to do it is to use JSTL instead of
> scriptlets
> like this:
>
> <c:choose>
> <c:when test="${day == 1}">
> <font color="blue" size="+1">Sunday</font>
> </c:when>
> <c:when test="${day == 2}">
> <font color="blue" size="+1">Monday</font>
> </c:when>
> <c:otherwise>
> <font color="blue" size="+1">No day</font>
> </c:otherwise>
> </c:choose>
>
> Much more readable, too.
>
> -Dave
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]