2011-09-16 11 views
2

について定義されていません:方法のgetContextPath()がここにある私のJSPタイプのServletContext

<HTML> 
<BODY > 
path : <%= application.getContextPath() %> 
</BODY> 
</HTML> 

このファイルには、Tomcat7とTomcat6に正しいですが、私はTomcatの私のCPanelのホスティングの5.32にJSPページを要求する場合、

org.apache.jasper.JasperException: Unable to compile class for JSP: 
An error occurred at line: 3 in the jsp file: /cal2.jsp 
The method getContextPath() is undefined for the type ServletContext 
1: <HTML> 
2: <BODY> 
3: path : <%= application.getContextPath() %> 
4: </BODY> 
5: </HTML> 
Stacktrace: 
    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:93) 
    org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330) 
    org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:451) 
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:328) 
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:307) 
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:295) 
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:565) 
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:309) 
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308) 
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259) 
    javax.servlet.http.HttpServlet.service(HttpServlet.java:72 

どのようにこの問題が発生し、どうすれば解決できますか?

答えて

10

getContextPath()メソッドは、バージョン2.5ではServletContextに追加されましたが、Tomcat 5は2.4のみ実装されています。しかし、request.getContextPath()も同じことをしています。

関連する問題