运行JSP时出现这个现象。。。

来源:百度知道 编辑:UC知道 时间:2024/05/23 16:51:54
用eclipse3.2+SQLserver2000+tomcat5.028+myeclipse5.5.1运行JSP,
用微软的SQLserverforJDBC连接数据库,
运行浏览器出现这个画面。。。

HTTP Status 500 -

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.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root cause

java.lang.NullPointerException
org.apache.jsp.index_jsp._jspService(index_jsp.java:84)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service

index.jsp的第84行出现了引用<%%>的代码,但是里面是个空对象,即没有实例化或者值的,这种问题不值得100分,浪费你自己的资源

public Connection getConnection() {
try {
Class.forName(driverName).newInstance();
return DriverManager.getConnection(url, user, password);
} catch (Exception err) {
return null;}

这里有可能直接返回了一null,你可以加个输出看看到底是执行的那里,你打开连接的方法有问题

public Connection getConnection() {
try {
Class.forName(driverName).newInstance();
System.out.println("上");
return DriverManager.getConnection(url, user, password);
} catch (Exception err) {
System.out.println("下");
return null;}

空指针异常 你调用了空的对象 是在JSP页面上调用的 你看看你的什么对象没有给引用

你的源代码上有一个从BEAN里面引用的 CON 你最好判断下他为不为空 否则的话会出问题

java.lang.NullPointerException
空指针异常,页面上带的集合为空
看看你自己写的代码,主要看数据库的连接和ACTION中的代码

private String user = "";
private String password = "";
用户名和密码都是空的,怎么连数据库啊

初学java最好学会怎样读懂错误信息