私は何を間違っていたのですか?
私はwin7のサービスとしてApachetomcat7を実行しています
私のjspコード[...\webapps \ test \ index.jsp]
<jsp:useBean id="Counter" scope="session" class="aaa.Counter" />
<html>
<title>sfcsv</title>
<%
try{
int x = Counter.read_count(),z = Counter.get_id();
if(x%2==0)
out.println(x + " = even");
else
out.println(x + " = odd");
out.println(z);
}catch(Exception e){
out.println(e);
}
%>
</html>
Javaコード[..\webapps \ test \ WEB-INF \ classes \ aaa \ Counter.java]
package aaa;
public class Counter {
private int count;
private static int instance_counter;
private final int id;
public Counter(){
instance_counter ++;
id = instance_counter;
count = 0;
}
public int read_count(){
return count++;
}
public int get_id(){
return id;
}
}
期待される出力:
24 = even 1
私が得ていた出力:
24 = even
また
HTTP Status 500 - Unable to compile class for JSP: An error occurred at line: 8 in the jsp file: /index.jsp The method get_id() is undefined for the type Counter 5: 6: <% 7: try{ 8: int x = Counter.read_count(),z = Counter.get_id(); 9: if(x%2==0) 10: out.println(x + " = even"); 11: else Stacktrace:
type Exception report
message Unable to compile class for JSP: An error occurred at line: 8 in the jsp file: /index.jsp The method get_id() is undefined for the type Counter 5: 6: <% 7: try{ 8: int x = Counter.read_count(),z = Counter.get_id(); 9: if(x%2==0) 10: out.println(x + " = even"); 11: else Stacktrace:
description The server encountered an internal error (Unable to compile class for JSP: An error occurred at line: 8 in the jsp file: /index.jsp The method get_id() is undefined for the type Counter 5: 6: <% 7: try{ 8: int x = Counter.read_count(),z = Counter.get_id(); 9: if(x%2==0) 10: out.println(x + " = even"); 11: else Stacktrace:) that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 8 in the jsp file: /index.jsp
The method get_id() is undefined for the type Counter
5:
6: <%
7: try{
8: int x = Counter.read_count(),z = Counter.get_id();
9: if(x%2==0)
10: out.println(x + " = even");
11: else
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:331)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:469)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.29 logs.
Apache Tomcat/7.0.29
編集:コンピュータを再起動すると、問題は消えました