You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jim Anderson <jj...@ptd.net.INVALID> on 2021/05/15 21:34:27 UTC
Tomcat JSP error message: Syntax error on token ";"
I'm using Tomcat 8.5.63 and in the last few days I started getting an error
message in a few of my JSP files. The error message is:
________________________START ERROR____________________________
Type Exception Report
Message Unable to compile class for JSP:
Description The server encountered an unexpected condition that prevented
it from fulfilling the request.
Exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: [1] in the jsp file: [/pages/list.jsp]
Syntax error on token ";", enum expected after this token
1: <%@ page language="java" contentType="text/html" %>
2: <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core
<http://java.sun.com/jsp/jstl/core>" %>
3: <%@ page import = "java.io.*,java.util.*" %>
4: <%@ page import="bfs.hypBeans.HypEvent" %>
_____________________________END ERROR___________________________________
As you can see, there is no semicolon in line 1 and the error message
is showing the code exactly as it is in the tomcat/webapps/... directory.
Can anyone help explain why a semi-colon error would be reported in the
error message when
it does not exist in the source code?
Thanks in advance for any advise/guindance.
Jim A.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Tomcat JSP error message: Syntax error on token ";"
Posted by Mark Thomas <ma...@apache.org>.
On May 17, 2021 9:32:42 PM UTC, Jim Anderson <jj...@ptd.net> wrote:
>
>I suspect there is an bug in tomcat.
There is no evidence to support that assertion.
> Should this be forwarded to the
>tomcat developers for consideration? If so, I will enter a report.
No. Any such report will be rejected as invalid.
>Narrowing down the test case to its simplest form has solved my
>problem.
>From my point of view, this issue is closed.
>
>My conclusion is that some reason, the line:
>
> *<%${test}%>*
>
>causes problems with Tomcat.
As per my previous email, that line is not valid. EL may not be used in scriplets. As a result, the compation fails and Tomcat passes on the error information provided by the compiler. With this sort of invalid input, it is not unusal for the compiler to be unable to pinpoint the exact location of the error.
Mark
> My solution is to test eliminate this line
>
>from my source code. It was for test purposes only anyway.
>
>
>Jim
>
>
>On 5/17/21 12:19 PM, Mark Thomas wrote:
>> Bringing this back on-list after it accidentality went off-list.
>>
>>
>> On 17/05/2021 16:43, Jim Anderson wrote:
>>>
>>> It took several hours to reduce the JSP file to a minimum, where the
>
>>> error still occurs, but here is the reduced file:
>>>
>>> <%@ page language="java" contentType="text/html" %>
>>> <html>
>>> <body>
>>> <%${test}%>
>>> </body>
>>> </html>
>>
>> The short version is that this is not a valid JSP.
>>
>> If you look at the generated Java code (in the work dir) somewhere
>> around line 116 you'll see:
>>
>> out.write("\n");
>> out.write("<html>\n");
>> out.write(" <body>\n");
>> out.write(" ");
>> ${'test'}
>> out.write("\n");
>> out.write(" </body>\n");
>> out.write("</html>\n");
>> out.write("\n");
>>
>> That won't compile. Hence the error.
>>
>> The syntax for "<% ... %>" (a.k.a a scriptlet) is that you need to
>> have valid Java code to replace the "...". "${test}" is not valid
>Java
>> code.
>>
>> Expression Language is not permitted within scriptlets.
>>
>> What are you trying to achieve here? At a guess you want something
>> like "<%= test %>" or "${test}" instead but it depends on your
>intention.
>>
>> Mark
>>
>>
>>
>>>
>>> If I remove the <%${test}%> line, the JSP pages gets process
>properly
>>> and displays a blank page, which is correct since there isn't
>>> anything in the HTML to be displayed.
>>>
>>> It was interesting to observer that when I ran my test cases, the
>>> typical time to run each iteration was 4 to 5 minutes, with two
>>> exceptions when the test case ran in under 2 seconds, and my guess
>is
>>> that it was under 1 second. The reduction process probably took
>about
>>> 50 test runs, but I did not count.
>>>
>>> I hope this helps.
>>>
>>> Jim*
>>> *
>>>
>>> On 5/16/21 12:56 PM, Mark Thomas wrote:
>>>> On 15/05/2021 22:34, Jim Anderson wrote:
>>>>> I'm using Tomcat 8.5.63 and in the last few days I started getting
>
>>>>> an error
>>>>> message in a few of my JSP files. The error message is:
>>>>>
>>>>> ________________________START ERROR____________________________
>>>>>
>>>>> Type Exception Report
>>>>>
>>>>> Message Unable to compile class for JSP:
>>>>>
>>>>> Description The server encountered an unexpected condition that
>>>>> prevented
>>>>> it from fulfilling the request.
>>>>>
>>>>> Exception
>>>>>
>>>>>
>>>>> org.apache.jasper.JasperException: Unable to compile class for
>JSP:
>>>>>
>>>>> An error occurred at line: [1] in the jsp file: [/pages/list.jsp]
>>>>> Syntax error on token ";", enum expected after this token
>>>>> 1: <%@ page language="java" contentType="text/html" %>
>>>>> 2: <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core
>>>>> <http://java.sun.com/jsp/jstl/core>" %>
>>>>> 3: <%@ page import = "java.io.*,java.util.*" %>
>>>>> 4: <%@ page import="bfs.hypBeans.HypEvent" %>
>>>>>
>>>>>
>>>>> _____________________________END
>>>>> ERROR___________________________________
>>>>>
>>>>>
>>>>> As you can see, there is no semicolon in line 1 and the error
>message
>>>>> is showing the code exactly as it is in the tomcat/webapps/...
>>>>> directory.
>>>>>
>>>>>
>>>>>
>>>>> Can anyone help explain why a semi-colon error would be reported
>in
>>>>> the error message when
>>>>> it does not exist in the source code?
>>>>
>>>> The ';' will be in the generated Java source code. Tomcat uses
>"Java
>>>> Debugging Support for Other Languages" to map errors in the Java
>>>> source to the associated line in the JSP.
>>>>
>>>> Compilation errors often don't map very well.
>>>>
>>>> You want to look at the generated source for the JSP (it will be in
>
>>>> the work directory) and see if you can figure out what is
>triggering
>>>> the error.
>>>>
>>>> Alternatively, post the source for the simplest standalone JSP that
>
>>>> triggers the issue and the people here can try and reproduce it.
>>>>
>>>> Mark
>>>>
>>>>
>---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Tomcat JSP error message: Syntax error on token ";"
Posted by Mark Thomas <ma...@apache.org>.
Bringing this back on-list after it accidentality went off-list.
On 17/05/2021 16:43, Jim Anderson wrote:
>
> It took several hours to reduce the JSP file to a minimum, where the
> error still occurs, but here is the reduced file:
>
> <%@ page language="java" contentType="text/html" %>
> <html>
> <body>
> <%${test}%>
> </body>
> </html>
The short version is that this is not a valid JSP.
If you look at the generated Java code (in the work dir) somewhere
around line 116 you'll see:
out.write("\n");
out.write("<html>\n");
out.write(" <body>\n");
out.write(" ");
${'test'}
out.write("\n");
out.write(" </body>\n");
out.write("</html>\n");
out.write("\n");
That won't compile. Hence the error.
The syntax for "<% ... %>" (a.k.a a scriptlet) is that you need to have
valid Java code to replace the "...". "${test}" is not valid Java code.
Expression Language is not permitted within scriptlets.
What are you trying to achieve here? At a guess you want something like
"<%= test %>" or "${test}" instead but it depends on your intention.
Mark
>
> If I remove the <%${test}%> line, the JSP pages gets process properly
> and displays a blank page, which is correct since there isn't anything
> in the HTML to be displayed.
>
> It was interesting to observer that when I ran my test cases, the
> typical time to run each iteration was 4 to 5 minutes, with two
> exceptions when the test case ran in under 2 seconds, and my guess is
> that it was under 1 second. The reduction process probably took about 50
> test runs, but I did not count.
>
> I hope this helps.
>
> Jim*
> *
>
> On 5/16/21 12:56 PM, Mark Thomas wrote:
>> On 15/05/2021 22:34, Jim Anderson wrote:
>>> I'm using Tomcat 8.5.63 and in the last few days I started getting an
>>> error
>>> message in a few of my JSP files. The error message is:
>>>
>>> ________________________START ERROR____________________________
>>>
>>> Type Exception Report
>>>
>>> Message Unable to compile class for JSP:
>>>
>>> Description The server encountered an unexpected condition that
>>> prevented
>>> it from fulfilling the request.
>>>
>>> Exception
>>>
>>>
>>> org.apache.jasper.JasperException: Unable to compile class for JSP:
>>>
>>> An error occurred at line: [1] in the jsp file: [/pages/list.jsp]
>>> Syntax error on token ";", enum expected after this token
>>> 1: <%@ page language="java" contentType="text/html" %>
>>> 2: <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core
>>> <http://java.sun.com/jsp/jstl/core>" %>
>>> 3: <%@ page import = "java.io.*,java.util.*" %>
>>> 4: <%@ page import="bfs.hypBeans.HypEvent" %>
>>>
>>>
>>> _____________________________END
>>> ERROR___________________________________
>>>
>>>
>>> As you can see, there is no semicolon in line 1 and the error message
>>> is showing the code exactly as it is in the tomcat/webapps/...
>>> directory.
>>>
>>>
>>>
>>> Can anyone help explain why a semi-colon error would be reported in
>>> the error message when
>>> it does not exist in the source code?
>>
>> The ';' will be in the generated Java source code. Tomcat uses "Java
>> Debugging Support for Other Languages" to map errors in the Java
>> source to the associated line in the JSP.
>>
>> Compilation errors often don't map very well.
>>
>> You want to look at the generated source for the JSP (it will be in
>> the work directory) and see if you can figure out what is triggering
>> the error.
>>
>> Alternatively, post the source for the simplest standalone JSP that
>> triggers the issue and the people here can try and reproduce it.
>>
>> Mark
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Tomcat JSP error message: Syntax error on token ";"
Posted by Mark Thomas <ma...@apache.org>.
On 15/05/2021 22:34, Jim Anderson wrote:
> I'm using Tomcat 8.5.63 and in the last few days I started getting an error
> message in a few of my JSP files. The error message is:
>
> ________________________START ERROR____________________________
>
> Type Exception Report
>
> Message Unable to compile class for JSP:
>
> Description The server encountered an unexpected condition that prevented
> it from fulfilling the request.
>
> Exception
>
>
> org.apache.jasper.JasperException: Unable to compile class for JSP:
>
> An error occurred at line: [1] in the jsp file: [/pages/list.jsp]
> Syntax error on token ";", enum expected after this token
> 1: <%@ page language="java" contentType="text/html" %>
> 2: <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core
> <http://java.sun.com/jsp/jstl/core>" %>
> 3: <%@ page import = "java.io.*,java.util.*" %>
> 4: <%@ page import="bfs.hypBeans.HypEvent" %>
>
>
> _____________________________END ERROR___________________________________
>
>
> As you can see, there is no semicolon in line 1 and the error message
> is showing the code exactly as it is in the tomcat/webapps/... directory.
>
>
>
> Can anyone help explain why a semi-colon error would be reported in the
> error message when
> it does not exist in the source code?
The ';' will be in the generated Java source code. Tomcat uses "Java
Debugging Support for Other Languages" to map errors in the Java source
to the associated line in the JSP.
Compilation errors often don't map very well.
You want to look at the generated source for the JSP (it will be in the
work directory) and see if you can figure out what is triggering the error.
Alternatively, post the source for the simplest standalone JSP that
triggers the issue and the people here can try and reproduce it.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org