Problems declaring a function in JSP with Tomcat 5

N

Neil

I have previosuly written a jsp page that used the syntax <%! to
declare some functions and it has worked fine in the past. I have got
a new computer and put Tomcat 5.0.29 on and now the pages don't work,
it gives the error:

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 108 in the jsp file: /index.jsp
Generated servlet error:
C:\Program Files\Apache Software Foundation\Tomcat
5.0\work\Catalina\localhost\_\org\apache\jsp\index_jsp.java:132: ')'
expected
{
^
The corresponding line in the code is:

<%!
public TreeNode buildTree(ResultSet results, TreeNode root, String
root)
{

I have removed the <%! blocks but then it gives me more errors about
unexpected declaration, it wants to see a ;

Has something changed in the spec about these kinds of declarations?

Thanks in advance.
 
H

Heiner Kücker

Neil wrote
I have previosuly written a jsp page that used the syntax <%! to
declare some functions and it has worked fine in the past. I have got
a new computer and put Tomcat 5.0.29 on and now the pages don't work,
it gives the error:

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 108 in the jsp file: /index.jsp
Generated servlet error:
C:\Program Files\Apache Software Foundation\Tomcat
5.0\work\Catalina\localhost\_\org\apache\jsp\index_jsp.java:132: ')'
expected
{
^
The corresponding line in the code is:

<%!
public TreeNode buildTree(ResultSet results, TreeNode root, String
root)
{

I have removed the <%! blocks but then it gives me more errors about
unexpected declaration, it wants to see a ;

Has something changed in the spec about these kinds of declarations?

The <%! sequence meant, the code is included in the class level in the jsp class:

puclic class jsp_xxxx {

-- your code ---

Must be code for sitting in the class declaration,
an variable or const declaration or an method.

The <% sequence meant, the code is included in the class level in the jsp class:

puclic class jsp_xxxx {

public void jspService() {

-- your code ---

Must be code for running in the jspService method.

Heiner Kuecker
Internet: http://www.heiner-kuecker.de
JSP WorkFlow FlowControl Navigation: http://www.control-and-command.de
Expression Parser: http://www.heinerkuecker.de/Expression.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,142
Latest member
arinsharma
Top