File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes JasperException Unable to compile class for JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JasperException Unable to compile class for JSP" Watch "JasperException Unable to compile class for JSP" New topic
Author

JasperException Unable to compile class for JSP

Benita Perkins
Greenhorn

Joined: Jul 18, 2008
Posts: 9
Hi

I have spent the past few days scouring forums and the net looking for a solution to this. I have read a lot of fixes but as yet haven't had any luck correcting the error.
The error is:
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

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

An error occurred at line: 263 in the generated java file
Syntax error, insert "else Statement" to complete IfStatement

An error occurred at line: 263 in the generated java file
Syntax error, insert "}" to complete Block

An error occurred at line: 273 in the generated java file
Syntax error on token "}", delete this token

An error occurred at line: 274 in the generated java file
Syntax error, insert "}" to complete ClassBody

Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.jav acError(Unknown Source)
org.apache.jasper.compiler.ErrorDispatcher.javacEr ror(Unknown Source)
org.apache.jasper.compiler.JDTCompiler.generateCla ss(Unknown Source)
org.apache.jasper.compiler.Compiler.compile(Unknow n Source)
org.apache.jasper.compiler.Compiler.compile(Unknow n Source)
org.apache.jasper.compiler.Compiler.compile(Unknow n Source)
org.apache.jasper.JspCompilationContext.compile(Un known Source)
org.apache.jasper.servlet.JspServletWrapper.servic e(Unknown Source)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(Unknown Source)
org.apache.jasper.servlet.JspServlet.service(Unkno wn Source)
javax.servlet.http.HttpServlet.service(Unknown Source)

note The full stack trace of the root cause is available in the Apache Tomcat/6.0-snapshot logs.
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
The url on the error page is:
10.0.0.241:8080/cca/docs/display_docs.jsp?cca_key=8356&field=cmpy_name&valu e=ROSE&type=Search&cmpyname=ROSE%20INNES%20AUCTION S%20CC&branch=East%20London®no=200407393023&dt= Thu%20Jul%2017%202008%2015:44:38%20GMT+0200%20(SAS T)
so I assume that the jsp in question is display_docs.jsp - but this script only has 126 lines.
I have found the class that is created but the class is created new at runtime of the application so editing that is pointless.

Is the error being caused due to the "Unknown Source"?
If this is causing the problem, where can I get the known source?


The code was developed in NetBeans 5.5 and is being run on an external server running Tomcat 6.
My servlet.jar is set as /usr/share/tomcat-servlet-api-2.5/lib/servlet-api.jar

I'm still searching but haven't had any luck.

Any input will be welcomed.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

exception

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

An error occurred at line: 263 in the generated java file
Syntax error, insert "else Statement" to complete IfStatement

An error occurred at line: 263 in the generated java file
Syntax error, insert "}" to complete Block

An error occurred at line: 273 in the generated java file
Syntax error on token "}", delete this token

An error occurred at line: 274 in the generated java file
Syntax error, insert "}" to complete ClassBody


The exception says it all, You have some mismatched if.. else statement in JSP scriptlet tag .

Post your JSP page , surrounded with code tag.


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Benita Perkins
Greenhorn

Joined: Jul 18, 2008
Posts: 9
This is the JSP.
The JSP only has 126 lines of code and the error is on line 263.... There is no other JSP with a name that is even similar to this.
I have had to change on click since I could not post this with the command in the code. The command is correct in the code
Any ideas?

Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

The compiler is telling you what the problem is, with line numbers.
It would be better for you to find this on your own than to have someone read the stack trace and point it out to you.

You're going to need to be able to do this a lot if you're going to be a programmer so, the sooner you become proficient at this, the easier life will be for you.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Benita Perkins
Greenhorn

Joined: Jul 18, 2008
Posts: 9
I don't mind finding the error on my own.
Would you be able to explain how the compiler for NetBeans 5.5 works and how or what it uses to build the classes for the jsp?
With this information, I'm sure I'll be able to hunt the error myself.

Thanks
Matteo Di Furia
Ranch Hand

Joined: Jun 20, 2008
Posts: 102
This :

never gets close, and this :



too.
Indeed, the compiler message tells you where to look. Just need a bit of work.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JasperException Unable to compile class for JSP