紧急求救,这是什么错误?

lci21 2001-06-02 06:59:00
我用的是tomcat,操作系统为98,我在测试jsp网站后台解决方案的一个程序时,总是出错,请大虾帮忙,不胜感激!
错误描述:
Error: 500
Location: /jsph/c11/register_action.jsp
Internal Servlet Error:

javax.servlet.ServletException
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:459)
at c_00031_00031._0002fc_00031_00031_0002fregister_0005faction_0002ejspregister_0005faction_jsp_4._jspService(_0002fc_00031_00031_0002fregister_0005faction_0002ejspregister_0005faction_jsp_4.java:131)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:177)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:484)

Root cause:
java.lang.NullPointerException
at c_00031_00031._0002fc_00031_00031_0002fregister_0005faction_0002ejspregister_0005faction_jsp_4._jspService(_0002fc_00031_00031_0002fregister_0005faction_0002ejspregister_0005faction_jsp_4.java:91)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:177)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:484)

程序(register.html):
<html>
<head>
<title>user register</title>
</head>
<body>
<table width="80%" align="center" border=1 cellspacing="0" cellpadding="0" bordercolordark="#88a6dd" bordercolorlight="#88a6dd">
<tr><td align="center" bgcolor="#88a6dd">用户注册</td></tr>
<tr>
<td align="center">
<form action="register_action.jsp">
<br>
用户名    <input type="text" name="userId" size=10>***<br><br>
密码      <input type="password" name="password" size=10>***<br><br>
确认密码  <input type="password" name="confirm_password" size=10>***<br><br>
性别    <input type="radio" name="sex" value="male" checked>男<input type="radio" name="sex" value="female">女<br><br>
住址      <input type="text" name="address" size=10>   <br><br>
联系电话  <input type="text" name="phone" size=10>   <br><br>
e-mail    <input type="text" name="mail" size=10>   <br><br>
学历      <select name="literacy" size="1">
<option selected value>bachelor</option>
<option>postdoctor</option>
<option>doctor</option>
<option>master</option>
<option>colleger</option>
<option>highschooler</option>
<option>primaryschooler</option>
</select>  <br><br>
职业      <select name="job" size="1">
<option selected value>manager</option>
<option>engineer</option>
<option>teacher</option>
<option>student</option>
<option>enterpriser</option>
<option>programmer</option>
<option>civilian</option>
<option>lawyer</option>
<option>other</option>
</select>  <br><br>
密码遗失提示问题    <input type="text" name="requestion" size="20">***   <br><br>
提示问题答案    <input type="text" name="answer" size="10">***   <br><br>

<input type="submit" value="完成">   
<input type="reset" value="重填"><br><br>
注:带***为必填项
</form>
</td>
</tr>
</table>
</body>
</html>

程序(register_action.jsp):
<%@page import="java.sql.*"%>

<html>
<head>
<title>user register</title>
</head>
<body>
<%
String userId=request.getParameter("userId");
String password=request.getParameter("password");
String confirm_password=request.getParameter("confirm_password");
String sex=request.getParameter("sex");
String phone=request.getParameter("phone");
String address=request.getParameter("address");
String mail=request.getParameter("mail");
String literacy=request.getParameter("literacy");
String job=request.getParameter("job");
String question=request.getParameter("question");
String answer=request.getParameter("answer");
%>
<%
if(sex.equals("male"))
sex="1";
else sex="0";
%>
<%
if((userId.length()==0)||(password.length()==0)||(confirm_password.length()==0))
out.println("userId,password or confirm_password not null!");
else if((question.length()==0)||(answer.length()==0))
out.println("question or answer not null!");
else if(mail.indexOf('@')<=0)
out.println("e-mail address wrong!");
else {
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:user_db";
Connection con=DriverManager.getConnection(url,"lci","");
PreparedStatement insert_stm=con.prepareStatement("inert into particular_user values(?,?,?,?,?,?,?,?,?,?)");
insert_stm.setString(1,userId);
insert_stm.setString(2,password);
insert_stm.setString(3,sex);
insert_stm.setString(4,address);
insert_stm.setString(5,phone);
insert_stm.setString(6,mail);
insert_stm.setString(7,literacy);
insert_stm.setString(8,job);
insert_stm.setString(9,question);
insert_stm.setString(10,answer);
try{
insert_stm.executeQuery();
}catch(Exception e) {}
con.close();
%>
<table border=1 cellspacing="0" cellpadding="0" bordercolordark="#88a6dd" bordercolorlight="#88a6dd" align="center">
<tr>
<td bgcolor="#88a6dd">现<br>在<br>登<br>录</td>
<td>
<table border=0 cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#88a6dd" align="center">你已经成功注册</td>
</tr>
<tr>
<td align="center">
<form action="particular_action.jsp">
用户<input type="text" name="userId" size=10><br>
密码<input type="password" name="password" size=10><br>
<input border=0 height=23 name="login" src="login.bmp" type=image width=52>
</form>
</td>
</tr>
</table>
</td>
</tr></table>
<%
}catch(Exception e){out.println(e);}
}
%>
</body>
</html>

数据库为sql server7.0
数据库:user_db,数据源user_db
表particular_user:
create table particular_user
(
userId varchar(10) not null,
password varchar(10) not null,
sex bit,
address varchar(50),
phone varchar(20),
e_mail varchar(30),
literacy varchar(20),
job varchar(20),
question varchar(30),
answer varchar(20)
);

请您一定帮帮忙啊!谢谢!谢谢!
...全文
59 点赞 收藏 5
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
steven_cheng 2001-06-04
给点儿分呀:)谢谢
回复
lci21 2001-06-04
非常感谢,原因已经查出来了,正是由于使用了空的String对象,后来把空串初始化为"",一切正常!thank you very much!!!
回复
steven_cheng 2001-06-04
java中的字符串是一个对象,在字符串比较前首先要保证不是NULL!!应该初始化字符串为空串,然后赋值,这样就不会有NULL的字符串出现了。你可以判断一下是不是因为字符串的问题。
回复
kalling 2001-06-03
NullPointerException,一般是由于你使用了某一个空(NULL)对象的方法
回复
liulinliu 2001-06-02
和数据库没有连上!!你不要打出上面的错误信息!那不是!!那是在服务器端由SERVLET抛出的列外,你要看TOMCAT下的(DOS窗口)下的出错信息!!
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2001-06-02 06:59
社区公告
暂无公告