tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "George Hester" <hesterl...@hotmail.com>
Subject Re: What's the problem with Tomcat 4.1.29 and Switch?
Date Tue, 24 Feb 2004 02:54:34 GMT
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" <parsonstechnical@earthlink.net> wrote in message news:02c601c3fa7e$8eba6770$7a01a8c0@ptslaptop...
> 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" <hesterloli@hotmail.com>
> To: <tomcat-user@jakarta.apache.org>
> 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: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message