当前位置: 技术问答>java相关
高分求解.请问我的这段代码为什么不行呀?
来源: 互联网 发布时间:2015-01-16
本文导语: 代码: New Page 3 其中test.bbsreg一个现成的连接数据库的类用的是jdbc-odbc,这个类肯定不会有问题 但是我的程序总是有错误:如下: Error: 500 Location: /bbslist.jsp Internal S...
代码:
New Page 3
其中test.bbsreg一个现成的连接数据库的类用的是jdbc-odbc,这个类肯定不会有问题
但是我的程序总是有错误:如下:
Error: 500
Location: /bbslist.jsp
Internal Servlet Error:
org.apache.jasper.JasperException: Unable to compile class for JSPC:tomcatworklocalhost_8080_0002fbbslist_0002ejspbbslist_jsp_2.java:37: ?? java.sql.SQLException ???????????? throws ???????
while (rst.next()){
^
C:tomcatworklocalhost_8080_0002fbbslist_0002ejspbbslist_jsp_2.java:40: ?????????out
out.print("");
^
C:tomcatworklocalhost_8080_0002fbbslist_0002ejspbbslist_jsp_2.java:41: ?????????out
out.print(tpc);
^
C:tomcatworklocalhost_8080_0002fbbslist_0002ejspbbslist_jsp_2.java:42: ?????????out
out.print("");
^
4 ???
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:254)
at org.apache.jasper.servlet.JspServlet.doLoadJSP(JspServlet.java:462)
at org.apache.jasper.servlet.JasperLoader12.loadJSP(JasperLoader12.java:146)
at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:433)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:152)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:164)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:484)
我实在是不知道什么地方错了,请指点!
New Page 3
其中test.bbsreg一个现成的连接数据库的类用的是jdbc-odbc,这个类肯定不会有问题
但是我的程序总是有错误:如下:
Error: 500
Location: /bbslist.jsp
Internal Servlet Error:
org.apache.jasper.JasperException: Unable to compile class for JSPC:tomcatworklocalhost_8080_0002fbbslist_0002ejspbbslist_jsp_2.java:37: ?? java.sql.SQLException ???????????? throws ???????
while (rst.next()){
^
C:tomcatworklocalhost_8080_0002fbbslist_0002ejspbbslist_jsp_2.java:40: ?????????out
out.print("");
^
C:tomcatworklocalhost_8080_0002fbbslist_0002ejspbbslist_jsp_2.java:41: ?????????out
out.print(tpc);
^
C:tomcatworklocalhost_8080_0002fbbslist_0002ejspbbslist_jsp_2.java:42: ?????????out
out.print("");
^
4 ???
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:254)
at org.apache.jasper.servlet.JspServlet.doLoadJSP(JspServlet.java:462)
at org.apache.jasper.servlet.JasperLoader12.loadJSP(JasperLoader12.java:146)
at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:433)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:152)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:164)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:484)
我实在是不知道什么地方错了,请指点!
|
同意vive(白起)。
另外,后面三个out错误,你可能应当把out用参数传进去,不能直接用。
public void listchild(PrintWriter out, String pid)
另外,后面三个out错误,你可能应当把out用参数传进去,不能直接用。
public void listchild(PrintWriter out, String pid)
|
我怀疑是next()这个方法会抛出一个SQLException,你外面要进行处理,加一个try{}catch(){}
|
同意hawaii(hawaii)
方法应改为:
public void listchild(javax.servlet.jsp.JspWriter out, String pid)
方法应改为:
public void listchild(javax.servlet.jsp.JspWriter out, String pid)
|
String sq="select * from bbs where parentid="+pid;
应改为:
String sq="select * from bbs where parentid= '"+pid + "'";
应改为:
String sq="select * from bbs where parentid= '"+pid + "'";
|
总结:
1.out.println在jsp的方法中不能直接使用,在jsp中可以
2.sq="select * from bbs where parentid="+pid;和sq="select * from bbs where parentid= '"+pid + "'";是两种写法,都是对的
1.out.println在jsp的方法中不能直接使用,在jsp中可以
2.sq="select * from bbs where parentid="+pid;和sq="select * from bbs where parentid= '"+pid + "'";是两种写法,都是对的
|
out.println在jsp的方法中应为System.out.println()
判断一下rs是否这空
判断一下rs是否这空
|
玩笑:
out和system.out是两码事
out和system.out是两码事
|
把这两行去掉看看,已经内含了,在引入的话,有的server会出错的
|
是不是你的记录为空?
|
对数据库操作异常也没捕捉。(try catch)
out把它当参数传进去!
out把它当参数传进去!