jsp 运行出错,请问高手,在线等.........
HTTPStatus500------------------------------------------------------------------------...
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: An exception occurred processing JSP page /confirm.jsp at line 18
15:
16: Statement stat=null;
17: try {
18: stat=conn.createStatement();
19: } catch (SQLException e1) {
20: // TODO Auto-generated catch block
21: e1.printStackTrace();
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:515)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:426)
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
java.lang.NullPointerException
org.apache.jsp.confirm_jsp._jspService(confirm_jsp.java:74)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384)
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.10 logs.
static String drivename="com.microsoft.jdbc.sqlserver.SQLServerDriver";
static String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=messageb";
static String name="sa";
static String pwd="";
static{
try {
Class.forName(drivename);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.print("加载驱动失败");
}
}
public static Connection getConnection(){
Connection conn=null;
try{
conn=(Connection)DriverManager.getConnection(url,name,pwd);
System.out.println("创建连接成功");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("创建连接失败");
}
return conn;
} 展开
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /confirm.jsp at line 18
15:
16: Statement stat=null;
17: try {
18: stat=conn.createStatement();
19: } catch (SQLException e1) {
20: // TODO Auto-generated catch block
21: e1.printStackTrace();
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:515)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:426)
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
java.lang.NullPointerException
org.apache.jsp.confirm_jsp._jspService(confirm_jsp.java:74)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384)
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.10 logs.
static String drivename="com.microsoft.jdbc.sqlserver.SQLServerDriver";
static String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=messageb";
static String name="sa";
static String pwd="";
static{
try {
Class.forName(drivename);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.print("加载驱动失败");
}
}
public static Connection getConnection(){
Connection conn=null;
try{
conn=(Connection)DriverManager.getConnection(url,name,pwd);
System.out.println("创建连接成功");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("创建连接失败");
}
return conn;
} 展开
4个回答
展开全部
空指针错误
conn是从外部引用的吧?看看包含进去没有
conn是从外部引用的吧?看看包含进去没有
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
明显是没获得数据库连接,没得到conn
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
空指针异常就是你的对象里头没有添值你需要看看你的数据库获取的连接对象是否为空,到你的tomcat下有个work的文件夹里头找到root cause:下所指定的地方是什么错误这样就可以自己进行测试修改了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询