I am working in a JSP project. While runnning the project using Netbeans with Tomcat 6 server, I got the following exception,
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 8 in the generated java file
Only a type can be imported. com.TransportPortal.MyFunctions resolves to a package
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:349)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:589)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
It has servelet-api.jar
in Apache Tomcat's lib
directory.
Please help me to resolve it.
From the error it seems that you are trying to import something which is not a class.
If your MyFunctions
is a class, you should import it like this:
<%@page import="com.TransportPortal.MyFunctions"%>
If it is a package and you want to import everything in the package you should do like this:
<%@page import="com.TransportPortal.MyFunctions.* "%>
Edit:
There are two cases which will give you this error, edited to cover both.
It may be related to Java JRE version.
In my case I need Tomcat 6.0.26 which presented same error with JRE 1.8.0_91. A downgrade to JRE 1.7.49 solved it.
You might find more information in: http://www.howopensource.com/2015/07/unable-to-compile-class-for-jsp-the-type-java-util-mapentry-cannot-be-resolved/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With