Interesting .
this works
<%
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>
<% } %>
no doubt some thing like this is occuring.
<% switch (day) { %> <- this \n gets translated to
switch(day){out.println("\r\n");
<% case 1: %> <- same here
case 1: out.println("\r\n");
etc .
Steve
Calin Duma wrote:
> 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: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]