0
这是我第一次尝试JSP。我正在使用TOMCAT8和Geany编写。我将应用程序文件夹放在/var/lib/tomcat8/webapps/Jproject
和/var/lib/tomcat8/webapps/Jproject/WEB-INF/classes
的类中。JSP导入类导致错误
我的课文件/var/lib/tomcat8/webapps/Jproject/WEB-INF/classes/test.class
是;
public class test
{
public static void PP()
{
System.out.println("yoyo");
}
}
和我的index.jsp (/var/lib/tomcat8/webapps/Jproject/index.jsp)
是;
<%@ page import="Jproject.test.*" %>
<DOCTYPE! html>
<html>
<head>
<title>Project</title>
</head>
<body>
<% String x = "java";
out.println("Hello " + x + "Worlds");
test.PP(); %>
</body>
</html>
当我在浏览器上运行它http://localhost:8080/Jproject/
我得到以下错误;
HTTP Status 500 - Unable to compile class for JSP:
type Exception report
message Unable to compile class for JSP:
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: 12 in the jsp file: /index.jsp
test cannot be resolved
9: String x = "java";
10:
11: out.println("Hello " + x + "Worlds");
12: test.PP();
13: %>
14: </body>
15: </html>
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:198)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:449)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:361)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:336)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:585)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:363)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:401)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:345)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
note The full stack trace of the root cause is available in the Apache Tomcat/8.0.32 (Ubuntu) logs.
Apache Tomcat/8.0.32 (Ubuntu)
我在做什么错了?谢谢你的帮助!
我没有使用eclipse。我正试图把它写在Geany上。有没有一个XML文件,我必须创建? – bluepinto