问题描述
在页面点击查询数据连接时,查询结果的页面出现错误,希望大虾们帮助小弟。出现错误严重:Servlet.service()forservletjspthrewexceptionorg.apache.jasper.JasperException:UnabletocompileclassforJSP:Stacktrace:atorg.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)atorg.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)atorg.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:435)atorg.apache.jasper.compiler.Compiler.compile(Compiler.java:298)atorg.apache.jasper.compiler.Compiler.compile(Compiler.java:277)atorg.apache.jasper.compiler.Compiler.compile(Compiler.java:265)atorg.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)atorg.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:299)atorg.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)atorg.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:803)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)atorg.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:691)atorg.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:469)atorg.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:403)atorg.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)atcom.v512.guestbook.GetMessageServlet.doGet(GetMessageServlet.java:49)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:690)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:803)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)atcom.v512.guestbook.EncodingFilter.doFilter(EncodingFilter.java:50)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)atorg.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)atorg.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)atorg.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)atorg.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)atorg.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)atorg.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)atorg.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)atorg.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)atorg.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)atorg.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)atorg.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)atjava.lang.Thread.run(Thread.java:619)AddMessageServlet.javapackagecom.v512.guestbook;importjava.io.IOException;importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.PreparedStatement;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.util.ArrayList;importjava.util.List;importjavax.servlet.ServletException;importjavax.servlet.http.HttpServlet;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse;publicclassGetMessageServletextendsHttpServlet{privatestaticfinallongserialVersionUID=-8349454122547148005L;publicvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,IOException{Stringdriver="oracle.jdbc.driver.OracleDriver";Stringurl="jdbc:oracle:thin:@10.36.65.232:1521:oracle9i";Stringusername="IAMS";Stringpassword="IAMS";Stringsql="select*fromguestbook";Connectionconn=null;PreparedStatementpstmt=null;ResultSetrs=null;try{Class.forName(driver);conn=DriverManager.getConnection(url,username,password);pstmt=conn.prepareStatement(sql);rs=pstmt.executeQuery();request.setCharacterEncoding("GBK");Listlist=newArrayList();while(rs.next()){Guestbookgb=newGuestbook();gb.setName(rs.getString("name"));gb.setEmail(rs.getString("email"));gb.setPhone(rs.getString("phone"));gb.setTitle(rs.getString("title"));gb.setContent(rs.getString("content"));System.out.println(rs.getString("name")+"+++++++");gb.setTime(rs.getString("time"));list.add(gb);}request.setAttribute("gblist",list);request.getRequestDispatcher("/getMessages.jsp").forward(request,response);}catch(Exceptione){Stringmessage=e.getMessage();request.setAttribute("message",message);request.getRequestDispatcher("/addResult.jsp").forward(request,response);}finally{try{pstmt.close();conn.close();}catch(SQLExceptione){e.printStackTrace();}}}}getMessages.jsp<%@pagelanguage="java"import="java.util.*"pageEncoding="GBK"%><%@pageimport="com.v512.guestbook.Guestbook,java.util.List,com.v512.util.StringUtil,java.sql.*"%><%@pageimport="org.apache.commons.dbutils.handlers.*"%><%@includefile="header.jsp"%><html><head><title>查看留言板</title></head><body><br><ahref="<%=context%>/addMessage.jsp">添加新的留言内容</a><br>留言内容<%Listgblist=(List)request.getAttribute("gblist");if(gblist.isEmpty()){out.print("数据库表没有信息");}else{Iteratori=gblist.Iterator();while(i.hasNext()){Guestbookgb=(Guestbook)i.next();%><divalign="center"><tablewidth="600"border="1"bordercolor="#000000"><tr><tdbordercolor="#FFFFFF">编号:</td><tdbordercolor="#FFFFFF"><%=gb.getId()%></td></tr><tr><tdbordercolor="#FFFFFF">姓名:</td><tdbordercolor="#FFFFFF"><%=gb.getName()%></td></tr><tr><tdbordercolor="#FFFFFF">电话:</td><tdbordercolor="#FFFFFF"><%=gb.getPhone()%></td></tr><tr><tdbordercolor="#FFFFFF">Email:</td><tdbordercolor="#FFFFFF"><%=gb.getEmail()%></td></tr><tr><tdbordercolor="#FFFFFF">主题:</td><tdbordercolor="#FFFFFF"><%=gb.getTitle()%></td></tr><tr><tdbordercolor="#FFFFFF">内容:</td><tdbordercolor="#FFFFFF"><%=gb.getContent()%></td></tr><tr><tdbordercolor="#FFFFFF">时间:</td><tdbordercolor="#FFFFFF"><%=gb.getTime()%></td></tr></table></div><%}%><br><br></body></html><%@includefile="footer.htm"%>
解决方案
解决方案二:
org.apache.jasper.JasperException:UnabletocompileclassforJSP:不能对jsp文件进行编印jre没配置好在开发工具重新构建项目时重新装载你的jdk
解决方案三:
你的Jsp不能编译,看一下哪里错了。
解决方案四:
atcom.v512.guestbook.GetMessageServlet.doGet(GetMessageServlet.java:49)这一行报错,看看这是哪一行。
解决方案五:
JSP里有错
解决方案六:
还是没有解决。
解决方案七:
<ahref="<%=context%>/addMessage.jsp">添加新的留言内容</a>里面的context来自于何处。