各位帮我看看,我这个jsp那儿有问题?谢谢,在线等。。。
使用的是tomcat,谢谢
代码如下:
<%
//继承Date类
java.util.Date dt=new java.util.Date();
hour=dt.getHot hours();
if((hour <11)&&(hour> =5))
out.println( "早上好! ");
if((hour <13)&&(hour> =11))
out.println( "中午好! ");
if((hour <18)&&(hour> =13))
out.println( "下午好! "));
if((hour <5)||(hour> =18))
out.println( "晚上好! ");
%>
网页中报错如下:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 1 in the jsp file: /test4.jsp
Generated servlet error:
hour cannot be resolved
An error occurred at line: 1 in the jsp file: /test4.jsp
Generated servlet error:
dt.getHot cannot be resolved or is not a field
An error occurred at line: 1 in the jsp file: /test4.jsp
Generated servlet error:
Syntax error, insert "; " to complete Statement
An error occurred at line: 1 in the jsp file: /test4.jsp
Generated servlet error:
The method hours() is undefined for the type test4_jsp
An error occurred at line: 1 in the jsp file: /test4.jsp
Generated servlet error:
hour cannot be resolved
An error occurred at line: 1 in the jsp file: /test4.jsp
Generated servlet error:
hour cannot be resolved
An error occurred at line: 1 in the jsp file: /test4.jsp
Generated servlet error:
hour cannot be resolved
An error occurred at line: 1 in the jsp file: /test4.jsp
Generated servlet error:
hour cannot be resolved
An error occurred at line: 1 in the jsp file: /test4.jsp
Generated servlet error:
hour cannot be resolved
An error occurred at line: 1 in the jsp file: /test4.jsp
Generated servlet error:
hour cannot be resolved
An error occurred at line: 1 in the jsp file: /test4.jsp
Generated servlet error:
Syntax error on token ") ", delete this token
An error occurred at line: 1 in the jsp file: /test4.jsp
Generated servlet error:
hour cannot be resolved
An error occurred at line: 1 in the jsp file: /test4.jsp
Generated servlet error:
hour cannot be resolved
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:565)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:354)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 1 in the jsp file: /test4.jsp
Generated servlet error:
hour cannot be resolved
An error occurred at line: 1 in the jsp file: /test4.jsp
Generated servlet error:
dt.getHot cannot be resolved or is not a field
An error occurred at line: 1 in the jsp file: /test4.jsp
Generated servlet error:
Syntax error, insert "; " to complete Statement
An error occurred at line: 1 in the jsp file: /test4.jsp
Generated servlet error:
The method hours() is undefined for the type test4_jsp
An error occurred at line: 1 in the jsp file: /test4.jsp
Generated servlet error:
hour cannot be resolved
An error occurred at line: 1 in the jsp file: /test4.jsp
Generated servlet error:
hour cannot be resolved
An error occurred at line: 1 in the jsp file: /test4.jsp
Generated servlet error:
hour cannot be resolved
An error occurred at line: 1 in the jsp file: /test4.jsp
Generated servlet error:
hour cannot be resolved
An error occurred at line: 1 in the jsp file: /test4.jsp
Generated servlet error:
hour cannot be resolved
An error occurred at line: 1 in the jsp file: /test4.jsp
Generated servlet error:
hour cannot be resolved
An error occurred at line: 1 in the jsp file: /test4.jsp
Generated servlet error:
Syntax error on token ") ", delete this token
An error occurred at line: 1 in the jsp file: /test4.jsp
Generated servlet error:
hour cannot be resolved
An error occurred at line: 1 in the jsp file: /test4.jsp
Generated servlet error:
hour cannot be resolved
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:329)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:415)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:314)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.2 logs.
[解决办法]
hour=dt.getHot hours();
应该是这行的方法名写错了
[解决办法]
Syntax error on token ") ", delete this token这个错误多明显啊!下次要小心
[解决办法]
酷鱼兄,变量先声明后使用这是最基本点原则啦,看来基础要再打牢固一点哦,呵呵
[解决办法]
out.println( "下午好! ")); 多加了括号~~
[解决办法]
建议你用Eclipse 这些问题它能帮你检查.
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html
我的异常网推荐解决方案:org.apache.jasper.JasperException: Unable to compile class,http://www.myexception.cn/j2ee/2308.html