Well according to Core JSP by Damon Hougland and Aaron Tavistock � 2001 Prentice Hall
(pgs 26-28) it should work.
For example this works:
<% if (day == 1 | day == 7){ %>
<font color="red" size="+1">
It's the weekend!</font>
<% } else { %>
<font color="red" size="+1">
Still in the work week.</font>
<% } %>
then why not the same for the switch? Note if breaking these tags up for the if -
then - else (as shown above) like in the switch I showed you then by transference we'd
have to conclude that the above if - then - else wouldn't work either. But it does.
So I'm confused. Why can we break the tags up in if - then - else but not in switch?
hmmm...
--
George Hester
__________________________________
"Parsons Technical Services" <[EMAIL PROTECTED]> wrote in message news:[EMAIL
PROTECTED]
> George,
>
> OK, I'll bite. Why?
>
> Not sure why you want to try this but from what I understand, no it won't
> work. The clue is that the jsp page is converted to a servlet and any code
> between the <% %> must stand on it own as valid code. When you split the
> code you have created two segments that if entered in a standard servlet
> could not stand on their own IF separated at ALL. Thus if the segregation
> was allowed then what would prevent you from inserting code between them?
> Thus when the servlet is created you then have two fragments of invalid code
> separated by other code. With that in mind, a simple test to determine if
> what you want is valid is to enter whatever you want between the <% %> in a
> standard class and see if it complains.
>
> Again this is from my understanding.
>
> Doug Parsons
> www.parsonstechnical.com
>
>
> ----- Original Message -----
> From: "George Hester" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, February 23, 2004 9:03 PM
> Subject: What's the problem with Tomcat 4.1.29 and Switch?
>
>
> In Tomacat this works fine:
>
> <-- switch.jsp -->
> <!-- BEGIN -->
> <!doctype html public "-//W3C//DTD HTML 4.0 Final//EN">
> <%
> int day = 3;
> %>
> <html>
> <head>
> <title>Test Switch</title>
> </head>
> <body>
> <% switch (day) {
> case 1:
> out.println("Sunday");
> break;
> case 2:
> out.println("Monday");
> break;
> default:
> out.println("No day");
> break;
> } %>
> </body>
> </html>
> <!-- END -->
>
> but this does NOT
>
> <-- switch.jsp -->
> <!-- BEGIN -->
> <!doctype html public "-//W3C//DTD HTML 4.0 Final//EN">
> <%
> int day = 3;
> %>
> <html>
> <head>
> <title>Test Switch</title>
> </head>
> <body>
> <% switch (day) { %>
> <% case 1:
> out.println("Sunday");
> break;
> case 2:
> out.println("Monday");
> break;
> default:
> out.println("No day");
> break;
> } %>
> </body>
> </html>
> <!-- END -->
>
> --
> George Hester
> __________________________________
>
>
> ---------------------------------------------------------------------
> 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]