java.lang.NullPointerException!
我曾经在21号的时候贴过这个问题,有很多朋友给我想出过这样那样的办法,我是个刚学几天的初学者,还是没能把这个问题解决了,这些代码都是我按照书上的例题做的,如果这个页面无法完成,其它的东西就都白做了,请诸位再帮忙看一下.希望能提出详细的解决方案.谢谢!尽我所能,把我170分中的100分都给您.
程序代码:
<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*"%>
<%!
Connection con=null;
Statement stmt=null;
ResultSet rs=null;
public void jspInit()
{
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:ClassDB");
stmt=con.createStatement(
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
}
catch(Exception ex)
{
System.out.println(ex.toString());
}
}
public void jspDestroy()
{
try{
rs.close();
stmt.close();
con.close();
}
catch(Exception ex)
{
System.out.println(ex.toString());
}
}
public String ShowContent(String strCon)
{
int SPos=0;
int EPos=0;
int totallen=strCon.length();
String strShow="";
char cr=13, If=10;
String strMid= null;
for(EPos=0;EPos<totallen;EPos++);
{
char c=strCon.charAt(EPos);
if(c==13)
{
if(EPos !=SPos)
{
strMid=strCon.substring(SPos,EPos);
strShow=strShow + ">" + strMid + cr + If;
}
else
strShow=strShow + ">" + cr + If;
SPos= EPos +2;
}
}
if(SPos<totallen)
{
strMid=strCon.substring(SPos,EPos);
strShow=strShow + ">" + strMid + cr + If;
}
return strShow;
}
%>
<html>
<head>
<title>讨论区</title>
<%
String RepID=request.getParameter("RepID");
String Title=request.getParameter("Title");
String PostID=request.getParameter("PostID");
%>
<script language="JavaScript">
<!--
function Abort(RID)
{
self.location="Content.jsp?ID=" + RID;
}
-->
</script>
</head>
<body>
<form action="<%="post.jsp?RepID=" + RepID%>" method="post" name="frmPost">
<P>发言人:
<INPUT name="Poster" style="height:25px;width:151px"></p>
<p>e-mail:<input name="e-mail" style="height:25px;width:383px"></p>
<p>标题:<input name="Title" style="height:25px;width:401px"></p>
<%
if(!RepID.equals("0"))
{
Title="Re:" + Title;
out.println("value=\"" + "Title" + "\"");
}
%></p>
内容:<br>
<textarea name="Content" style="height:155px;width:601px">
<%
String strSQL=null;
if(!RepID.equals("0"))
{
strSQL="SELECT Content FROM Board WHERE ID=" + " PostID ";
rs=stmt.executeQuery("strSQL");
rs.next();
out.println(ShowContent(rs.getString("Content")));
}
else
{
strSQL="SELECT ID FROM Board" + " WHERE RepID=0 ORDER BY LastRep DESC ";
rs=stmt.executeQuery(strSQL);
rs.next();
RepID=rs.getString("ID");
}
%>
</textarea>
<p><input name="submit1" type="submit" value="张贴">
<input name="reset1" type="reset" value="我要重新写">
<input type="button" value="放弃" name="botton1" onclick="Abort(<%=RepID%>)">
</p>
</form>
</body>
</html>