tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Calin Duma <cd...@ecologic.net>
Subject Jasper question
Date Tue, 20 Feb 2001 20:47:08 GMT
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

Mime
View raw message