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
MyFunctionsis a class, you should import it like this:If it is a package and you want to import everything in the package you should do like this:
Edit:
There are two cases which will give you this error, edited to cover both.