新手求教,初学JSP出现HTTP Status 500错误,我用的是myeclipse连接oracle数据库
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 /searcher/aInforFromDB.jsp at line 35
32:
33: <table width="469" height="90" border="0" align="center" bgcolor="#FFFFFF">
34: <tr >
35: <td height="32" colspan="2" align="center" class="style1"><%=infor[0]%><hr width="90%" size="1" color="#000000"> </td>
36: </tr>
37: <tr>
38: <td width="197" height="20"><div align="right"><span class="style2" ><%=infor[3]%></span></div></td>
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:435)
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.searcher.aInforFromDB_jsp._jspService(aInforFromDB_jsp.java:108)
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:393)
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.14 logs.
Apache Tomcat/6.0.14
【附】aInforFromDB.jsp程序
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="searcher.dbManager.*,searcher.*" %>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>知识条</title>
<style type="text/css">
<!--
.style1 {
font-family: "隶书";
font-size: 36px;
color: #385FA4;
}
.style2 {font-size: 12px; color:#999999}
.style3 {font-size: 12px; color: #000000}
-->
</style>
</head>
<body>
<%
String NO= toChi(request.getParameter("NO"));
dbToObject dbToObject1 = new dbToObject();
String[] infor = dbToObject1.getARecord(NO);
/*String content = infor[1];
*/
%>
<table border="0" align="center" cellpadding="0" cellspacing="1" bordercolor="#FFFFFF" bgcolor="#385FA4" >
<tr bgcolor="#FFFFFF">
<td width="471" >
<table width="469" height="90" border="0" align="center" bgcolor="#FFFFFF">
<tr >
<td height="32" colspan="2" align="center" class="style1"><%=infor[0]%><hr width="90%" size="1" color="#000000"> </td>
</tr>
<tr>
<td width="197" height="20"><div align="right"><span class="style2" ><%=infor[3]%></span></div></td>
<td width="296"><div align="right"></div></td>
</tr>
<tr>
<td height="20" colspan="2" >
<div align="left"><span class="style2"><%=infor[1]%></span></div></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
<%!
public String toChi(String input) {
try {
if( input==null)
{
return null;
}
byte[] bytes = input.getBytes("ISO8859-1");
return new String(bytes);
//String bytes=new String(input.getBytes("ISO8859-1"),"UTF-8");
//return bytes;
}catch(Exception ex) {
}
return null;
}
%>
</html>
--------------------编程问答-------------------- String[] infor = dbToObject1.getARecord(NO);
能否确保infor里面有数据?建议先做个单元测试 --------------------编程问答-------------------- 错误信息:JSP page /searcher/aInforFromDB.jsp at line 35,
java.lang.NullPointerException
也就是说infor为null,没有获取数据 --------------------编程问答-------------------- 空指针异常
补充:Java , Java EE