Eclipse jee版本 开发jsp问题

09-09-17 yuliu312832473

我用hibernate开发一个连接数据库的jsp如下(怎么都无法执行)

请问各位老师 到底哪里出错了

jsp文件如下:

//--------------------------------------

<%@ page import="java.util.*,lizhx.test.Person,lizhx.test.dao.*" errorPage="error.jsp" %>

<%@ page import="org.hibernate.*,org.hibernate.criterion.*" %>

<%

try{

_RootDAO.initialize();

PersonDAO persondao=new PersonDAO();

Criteria criteria=

(persondao.getSession()).createCriteria(Person.class);

criteria.add(Expression.eq("Sex","M"));

List p=criteria.list();

out.println("The Man persons="+p.size());

}

catch(Exception e)

{

out.println(e.getMessage());

}

%>

//----------------------------------------------------

错误消息:

严重: Servlet.service() for servlet jsp threw exception

org.apache.jasper.JasperException: Unable to compile class for JSP:

Stacktrace:

at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)

at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)

at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:415)

at org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)

at org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)

at org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)

at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)

at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308)

at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)

at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216)

at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:866)

at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:716)

at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1498)

at java.lang.Thread.run(Unknown Source)

2009-9-17 15:59:46 org.apache.catalina.core.StandardWrapperValve invoke

严重: Servlet.service() for servlet jsp threw exception

java.lang.ClassNotFoundException: org.apache.jsp.MyJsp_jsp

at java.net.URLClassLoader$1.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(Unknown Source)

at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:134)

at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:66)

at org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:598)

at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:142)

at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:320)

at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)

at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216)

at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:866)

at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:716)

at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1498)

at java.lang.Thread.run(Unknown Source)

2009-9-17 16:00:12 org.apache.catalina.core.StandardWrapperValve invoke

严重: Servlet.service() for servlet jsp threw exception

org.apache.jasper.JasperException: Unable to compile class for JSP:

高手做出来了发我邮箱312832473@qq.com

banq
2009-09-17 17:22

你这样使用JSP是错误的,必须使用MVC模式。

将界面显示和DAO数据库访问进行分离,使用Java类实现数据类,这样,编译错误就可以准确地显示行数,也可以断点调试。

[该贴被banq于2009-09-17 17:23修改过]

zzxsky1986
2009-09-18 09:26

这个问题不是程序的问题。这是一个服务器无法编译jsp文件的问题。肯定是你的应用服务器的jdk没有配置好,eclipse配置服务器的jdk知道吧。看看jdk的版本,如果使用的是tomcat试试把tomcat目录下的work文件夹中的内容删除部署一下(编译过程)