tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "mailinglists@returnpath.net" <mailingli...@returnpath.net>
Subject Re: Jasper question
Date Tue, 20 Feb 2001 20:44:31 GMT
Try this:

SampleGood.jsp
-------------
<%
   // A calendar object is created to get an integer value
   // of the current day of the week
      java.util.Calendar thisCal = java.util.Calendar.getInstance();
      int day = thisCal.get(thisCal.DAY_OF_WEEK);
%>

<% switch (day) { 
       case 1: %>
    <FONT COLOR="blue" SIZE="+1">Sunday</FONT>
    <% break; 
      case 2: %>
    <FONT COLOR="blue" SIZE="+1">Monday</FONT>
    <% break; 
     case 3: %>
    <FONT COLOR="blue" SIZE="+1">Tuesday</FONT>
    <% break; 
     default: %>
    <FONT COLOR="blue" SIZE="+1">Any other day.</FONT>
<% } %>

Hope this helps

Rory

----- Original Message ----- 
From: "Calin Duma" <cduma@ecologic.net>
To: <tomcat-user@jakarta.apache.org>
Sent: Tuesday, February 20, 2001 3:47 PM
Subject: Jasper question


> Hello Tomcaters,
> 
> I am trying to embed a java code fragment in a jsp scriptlet.  Whenever
> I'm using the switch / case statements I get Jasper compilation errors:
> 
> SampleBad.jsp
> -------------
> <%
>    // A calendar object is created to get an integer value
>    // of the current day of the week
>       java.util.Calendar thisCal = java.util.Calendar.getInstance();
>       int day = thisCal.get(thisCal.DAY_OF_WEEK);
> %>
> 
> <% switch (day) { %>
> <% case 1: %>
>     <FONT COLOR="blue" SIZE="+1">Sunday</FONT>
>     <% break; %>
> <% case 2: %>
>     <FONT COLOR="blue" SIZE="+1">Monday</FONT>
>     <% break; %>
> <% case 3: %>
>     <FONT COLOR="blue" SIZE="+1">Tuesday</FONT>
>     <% break; %>
> <% default: %>
>     <FONT COLOR="blue" SIZE="+1">Any other day.</FONT>
> <% } %>
> 
> Extraneous out.write("\r\n") are generated and produce "Unreachable
> statement" errors during the JSP compilation.  I am using JBuilder 4.0
> on Windows NT as my IDE (editor).
> 
> It works if I take the <CR><LF> out of the above page.  Am I missing
> something or is this a bug ?
> 
> SampleGood.jsp
> --------------
> <%
>    // A calendar object is created to get an integer value
>    // of the current day of the week
>       java.util.Calendar thisCal = java.util.Calendar.getInstance();
>       int day = thisCal.get(thisCal.DAY_OF_WEEK);
> %>
> 
> <% switch (day) { %><% case 1: %>
>     <FONT COLOR="blue" SIZE="+1">Sunday</FONT>
>     <% break; %><% case 2: %>
>     <FONT COLOR="blue" SIZE="+1">Monday</FONT>
>     <% break; %><% case 3: %>
>     <FONT COLOR="blue" SIZE="+1">Tuesday</FONT>
>     <% break; %><% default: %>
>     <FONT COLOR="blue" SIZE="+1">Any other day.</FONT>
> <% } %>
> 
> Any input would be appreciated.
> 
> Thanks,
> 
> Calin Duma
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, email: tomcat-user-help@jakarta.apache.org
> 
> 
> 


Mime
View raw message