You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Rodney J. Lucas" <lu...@progress.com> on 2001/07/31 14:27:32 UTC

white space in JSP

using Tomcat 4.0b5, Java 1.3.1 on Solaris

I ran across a problem while trying to learn how to program with
tomcat/jsp.  Any comments or advice would be welcome

I was running a simple case statement and got an error stating
"Statement
not reached".
=============================
Error: 500
Location: /lucas/switch.jsp
Internal Servlet Error:

org.apache.jasper.JasperException: Unable to compile class for
JSPC:\bin\tomcat\3.2.3\work\localhost_8080%2Flucas\_0002fswitch_0002ejspswit

ch_jsp_3.java:74: Statement not reached.
                out.write("\t\r\n\r\n");
                ^
===============================

I couldn't figure this out for a while until I understood out how to
view
the java produced by the jsp code.  Because my case statement had
whitespaces between jsp tags the jasper engine decided to produce
out.write
statements in the wrong place.

I modified my jsp to work but I wanted to ask if this was a bug.
I can just format my code differently, but it seems like a error other
newbies would make and I am sure it can get a bit nastier with more
complicated code. Is this behaviour part of the spec or can I expect
different implementations to behave differently.

Rodney

Here is a listing to reproduce the error.  I have fixed most of the
whitespace problem expect for the case statement just before monday.

==============================
<%!
java.util.Calendar todaysDate= java.util.Calendar.getInstance();
int myDay = todaysDate.get(todaysDate.DAY_OF_WEEK);
%>

<html>
<head>
<title>SWITCH</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>

<body bgcolor="#FFFFFF" text="#000000">
<p><font size="-1" color="red">

<% switch (myDay) {
        case 1: %>
                Today is Sunday
<%              break; %>

<%      case 2: %>
                Today is Monday
<%              break;

        case 3: %>
                Today is Tuesday
<%              break;
        case 4: %>
                Today is Wednesday
<%              break;
        case 5:%>
                Today is Thursday
<%              break;
        case 6: %>
                Today is Friday
<%              break;
        case 7: %>
                Today is Saturday
<%              break;
        default: %>
                Invalid day of the week:
<%              break;
} %>

</font></p>
</body>
</html>


Re: white space in JSP

Posted by "Rodney J. Lucas" <lu...@progress.com>.
thanks but that didn't work.  This has the same problem on Windows2000.


Hariharasubramanian Ranganathan wrote:

> Check for any "null" character (ascii 0) that might be placed in your JSP
> file accidently.
> 
> - Hari.
> 
> ----- Original Message -----
> From: "Rodney J. Lucas" <lu...@progress.com>
> To: <to...@jakarta.apache.org>
> Sent: Tuesday, July 31, 2001 5:57 PM
> Subject: white space in JSP
> 
> 
> 
>>using Tomcat 4.0b5, Java 1.3.1 on Solaris
>>
>>I ran across a problem while trying to learn how to program with
>>tomcat/jsp.  Any comments or advice would be welcome
>>
>>I was running a simple case statement and got an error stating
>>"Statement
>>not reached".
>>=============================
>>Error: 500
>>Location: /lucas/switch.jsp
>>Internal Servlet Error:
>>
>>org.apache.jasper.JasperException: Unable to compile class for
>>
>>
> JSPC:\bin\tomcat\3.2.3\work\localhost_8080%2Flucas\_0002fswitch_0002ejspswit
> 
>>ch_jsp_3.java:74: Statement not reached.
>>                out.write("\t\r\n\r\n");
>>                ^
>>===============================
>>
>>I couldn't figure this out for a while until I understood out how to
>>view
>>the java produced by the jsp code.  Because my case statement had
>>whitespaces between jsp tags the jasper engine decided to produce
>>out.write
>>statements in the wrong place.
>>
>>I modified my jsp to work but I wanted to ask if this was a bug.
>>I can just format my code differently, but it seems like a error other
>>newbies would make and I am sure it can get a bit nastier with more
>>complicated code. Is this behaviour part of the spec or can I expect
>>different implementations to behave differently.
>>
>>Rodney
>>
>>Here is a listing to reproduce the error.  I have fixed most of the
>>whitespace problem expect for the case statement just before monday.
>>
>>==============================
>><%!
>>java.util.Calendar todaysDate= java.util.Calendar.getInstance();
>>int myDay = todaysDate.get(todaysDate.DAY_OF_WEEK);
>>%>
>>
>><html>
>><head>
>><title>SWITCH</title>
>><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
>>
>></head>
>>
>><body bgcolor="#FFFFFF" text="#000000">
>><p><font size="-1" color="red">
>>
>><% switch (myDay) {
>>        case 1: %>
>>                Today is Sunday
>><%              break; %>
>>
>><%      case 2: %>
>>                Today is Monday
>><%              break;
>>
>>        case 3: %>
>>                Today is Tuesday
>><%              break;
>>        case 4: %>
>>                Today is Wednesday
>><%              break;
>>        case 5:%>
>>                Today is Thursday
>><%              break;
>>        case 6: %>
>>                Today is Friday
>><%              break;
>>        case 7: %>
>>                Today is Saturday
>><%              break;
>>        default: %>
>>                Invalid day of the week:
>><%              break;
>>} %>
>>
>></font></p>
>></body>
>></html>
>>
> 
> 



Re: white space in JSP

Posted by Hariharasubramanian Ranganathan <ha...@kumaran.com>.
Check for any "null" character (ascii 0) that might be placed in your JSP
file accidently.

- Hari.

----- Original Message -----
From: "Rodney J. Lucas" <lu...@progress.com>
To: <to...@jakarta.apache.org>
Sent: Tuesday, July 31, 2001 5:57 PM
Subject: white space in JSP


> using Tomcat 4.0b5, Java 1.3.1 on Solaris
>
> I ran across a problem while trying to learn how to program with
> tomcat/jsp.  Any comments or advice would be welcome
>
> I was running a simple case statement and got an error stating
> "Statement
> not reached".
> =============================
> Error: 500
> Location: /lucas/switch.jsp
> Internal Servlet Error:
>
> org.apache.jasper.JasperException: Unable to compile class for
>
JSPC:\bin\tomcat\3.2.3\work\localhost_8080%2Flucas\_0002fswitch_0002ejspswit
>
> ch_jsp_3.java:74: Statement not reached.
>                 out.write("\t\r\n\r\n");
>                 ^
> ===============================
>
> I couldn't figure this out for a while until I understood out how to
> view
> the java produced by the jsp code.  Because my case statement had
> whitespaces between jsp tags the jasper engine decided to produce
> out.write
> statements in the wrong place.
>
> I modified my jsp to work but I wanted to ask if this was a bug.
> I can just format my code differently, but it seems like a error other
> newbies would make and I am sure it can get a bit nastier with more
> complicated code. Is this behaviour part of the spec or can I expect
> different implementations to behave differently.
>
> Rodney
>
> Here is a listing to reproduce the error.  I have fixed most of the
> whitespace problem expect for the case statement just before monday.
>
> ==============================
> <%!
> java.util.Calendar todaysDate= java.util.Calendar.getInstance();
> int myDay = todaysDate.get(todaysDate.DAY_OF_WEEK);
> %>
>
> <html>
> <head>
> <title>SWITCH</title>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
>
> </head>
>
> <body bgcolor="#FFFFFF" text="#000000">
> <p><font size="-1" color="red">
>
> <% switch (myDay) {
>         case 1: %>
>                 Today is Sunday
> <%              break; %>
>
> <%      case 2: %>
>                 Today is Monday
> <%              break;
>
>         case 3: %>
>                 Today is Tuesday
> <%              break;
>         case 4: %>
>                 Today is Wednesday
> <%              break;
>         case 5:%>
>                 Today is Thursday
> <%              break;
>         case 6: %>
>                 Today is Friday
> <%              break;
>         case 7: %>
>                 Today is Saturday
> <%              break;
>         default: %>
>                 Invalid day of the week:
> <%              break;
> } %>
>
> </font></p>
> </body>
> </html>
>