高手救命啊请教jsp问题。
HTTP Status 500 - java.lang.NullPointerException
--------------------------------------------------------------------------------
type Exception report
message java.lang.NullPointerException
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: java.lang.NullPointerException
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
root cause
java.lang.NullPointerException
org.apache.jsp.index_jsp._jspService(index_jsp.java:149)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.47 logs.
以上为打开的报错内容
在服务器上可以使用,我把SQL库完全备份到这台机器,源码也发在这台机器上,一样的环境,为啥不行呢?
另外问一下,SQL链接的用户和密码,哪张表在TOMCAT的哪里?
[解决办法]
<%@ page contentType="text/html; charset=gb2312" errorPage="" %>
<%@ page import="java.sql.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.Date"%>
<%@ page import="java.text.*"%>
<jsp:useBean id="Databbb" scope="page" class="com.db.CGlobalFunction" />
<%Databbb.getConn(config);%>
<%
ResultSet rs;
String mysql,sYear="",aaid="",sName="";
String txtsrid="",txtname="";
txtsrid = (String)request.getParameter("txtsrid");
txtname = Databbb.toChinese(request.getParameter("txtname"));
String txtsrid1 = (String)request.getParameter("txtsrid1");
String txtname1 = (String)request.getParameter("txtname1");
if (txtsrid==null){ if(txtsrid1==null) {aaid = "";} else {aaid=txtsrid1;}} else {aaid = txtsrid;}
if (txtname==null){ if(txtname1==null) {aaname= "";} else {sName=txtname1;}} else {aaname= txtname;}
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
<link href="css/xmwuye.css" rel="stylesheet" type="text/css">
<link href="../css/xmwuye.css" rel="stylesheet" type="text/css">
</head>
<body>
<form name="studform" method="post" action="" autocomplete="off">
<table width="70%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr bgcolor="#F2F8FF">
<td width="12%"><strong>号码:</strong></td>
<td width="35%"><input name="txtsrid" type="text" id="txtsrid" value="<%=aaid%>" size="19"></td>
<td width="12%"><strong>新号码:</strong></td>
<td width="28%"><input name="txtname" type="text" id="txtname" value="<%=sName%>" size="19"></td>
<td width="13%"><input type="submit" name="Submit" value="提交"></td>
</tr>
</table>
<p> </p>
<p>
<%
mysql = " select b.idname,b.srid,b.stdname,case b.sex when '1' then '男' when '2' then '女' end ";
mysql += " as sex1,b.jiebie,b.isdelete,b.iid,b.photopath, ";
mysql += " case substring(b.email,5,1) when '2' then '已算' else '未算' end as zkzt ";
mysql += " from saavrdb ";
mysql += " where substring(b.srid,1,1)='3' " ;
if (aaid.equals("")){} else { mysql += " and b.srid like '" + aaid + "%'"; }
if (sName.equals("")){} else { mysql += " and b.iid like '" + aaname+ "%'";}
if (aaid.equals("")&&sName.equals("")) { mysql += " and b.srid = 'nick' ";}
rs=Databbb.selectSQLExec(mysql);
int intPageSize; //一页显示的记录数
int intRowCount; //记录总数
int intPageCount; //总页数
int intPage; //待显示页码
String strPage;
int i;
intPageSize = 20;
strPage = request.getParameter("pages");
if(strPage==null){
intPage = 1;
}
else
{
intPage = Integer.parseInt(strPage);
if(intPage<1){ intPage = 1;}
}
rs.last();
intRowCount = rs.getRow();
intPageCount =(intRowCount+intPageSize-1) / intPageSize;
if(intPage>intPageCount) intPage = intPageCount;
if(intPageCount>0){
rs.absolute((intPage-1) * intPageSize+1);
i = 0;
%>
</p>
<table width="70%" border="0" align="center" cellpadding="2" cellspacing="1" class="table002">
<tr bgcolor="#F2F8FF">
<td width="25%" height="21"><strong>名称</strong></td>
<td width="15%"><strong>号码码</strong></td>
<td width="15%"><strong>学生姓名</strong></td>
<td width="5%"><strong>性别</strong></td>
<td width="5%"><strong>届别</strong></td>
<td width="15%"><strong>新号码</strong></td>
<td width="10%"><strong>新状态</strong></td>
<td width="5%"><strong>旧状态</strong></td>
</tr>
<%
while(i< intPageSize && !rs.isAfterLast()){
i ++;
if ((i%2)!=1)
{
%>
<tr bgcolor="#F2F8FF">
<%
}
%>
<td height="21"><%=rs.getString("idname")%></td>
<td><%=rs.getString("srid")%></td>
<td><%=rs.getString("stdname")%></td>
<td><%=rs.getString("sex1")%></td>
<td><%=rs.getString("jiebie")%></td>
<td><%=rs.getString("iid")%></td>
<td><%=rs.getString("photopath")%></td>
<td><%=rs.getString("zkzt")%></td>
</tr>
<%
rs.next();
}
}
%>
</table>
<table width="70%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="53%" height="25" class=td005>
<div align="left">
<%out.print("共<font color=red>"+intRowCount+"</font>条 <font color=red>"+intPageSize+"</font>/页 共<font color=red>"+intPageCount+"</font>页");%>
当前第<font color=red><%=intPage%></font>页 </div></td>
<td width="47%" class=td005>
<div align="right">
<%if(intPage<=1){%>
首页
<%}else{%>
<a href="index.jsp?pages=1&txtsrid1=<%=aaid%>&txtname1=<%=sName%>"></a>
<%}%>
<%if(intPage>1){%>
<a href="index.jsp?pages=<%=intPage-1%>&txtsrid1=<%=aaid%>&txtname1=<%=sName%>">上一页</a>
<%}else{%>
上一页
<%
}%>
<%if(intPage<intPageCount){%>
<a href="index.jsp?pages=<%=intPage+1%>&txtsrid1=<%=aaid%>&txtname1=<%=sName%>">下一页</a>
<%}else{%>
下一页
<%}%>
<%if(intPageCount<=1
[解决办法]
intPage==intPageCount){%>
尾页
<%}else{%>
<a href="index.jsp?pages=<%=intPageCount%>&txtsrid1=<%=aaid%>&txtname1=<%=sName%>">尾页</a>
<%}%>
</div></td>
</tr>
</table>
<p> </p>
</form>
</body>
</html>