JSP新手问题

li610 2008-04-26 10:39:26
我是一个新手,我有一个系统,数据库是MYSQL4.1的,服务器用tomcat5,jdk是1.6的,有几个页面老是出现500错误显示不出来,这是一个参考书上的系统,应该没什么问题了,我也完全按照步骤做了,就不知道怎么回事了。系统我上传到了一个网盘里,附件传不上,请各位大虾帮忙看看是系统本来的问题还是我机子的问题.
文件地址为:http://www.fs2you.com/files/5c32ccc7-139e-11dd-b95c-0014221f4662/
...全文
91 点赞 收藏 9
写回复
9 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
li610 2008-04-27
连了数据库之后又出现以下错误:
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
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:460)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause

java.lang.NullPointerException
org.apache.jsp.userRegister_jsp._jspService(userRegister_jsp.java:190)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.26 logs.
又跟上面的错误不同了这是怎么回事啊

回复
tomiehu 2008-04-27
没有处理异常应该编译也不会通过的。
回复
li610 2008-04-26
那这个数据库怎么连呢,我不太会.我就是把MSYQL打开导入数据库就完了
回复
临远 2008-04-26
dbconns是null的,连接数据库失败。
回复
evoloyeu 2008-04-26
139行没有异常处理,用try{}catch(){}捕获异常
回复
li610 2008-04-26
错误代码如下:
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: Exception in JSP: /userRegister.jsp:139

136: <td>
137: <%
138: String strSqlworkgroups="";
139: Statement stmtworkgroups=dbconn.getConnection().createStatement();
140: strSqlworkgroups="select * from `workgroup` where tag=0 order by id";
141: ResultSet rsworkgroups=stmtworkgroups.executeQuery(strSqlworkgroups);
142: while(rsworkgroups.next())


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:451)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause

java.lang.NullPointerException
org.apache.jsp.userRegister_jsp._jspService(userRegister_jsp.java:190)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.26 logs.


--------------------------------------------------------------------------------

Apache Tomcat/5.5.26
页面代码如下:
<%@ page language="java" contentType="text/html;charset=gb2312" %>
<%@ page import="java.sql.*"%>
<jsp:useBean id="dbconn" scope="application" class="com.am.OpenDB"/>
<html>
<head>
<title>写作大赛报名系统</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language=javascript>
<!--
function checkform()
{
if (FORM1.txtusername.value=="") {
alert( "请填写用户名." );
FORM1.txtusername.focus();
return false;
}
if (FORM1.txtuserPassword.value=="") {
alert( "请填写密码." );
FORM1.txtuserPassword.focus();
return false;
}
if (FORM1.txtuserPassword1.value=="") {
alert( "请填写确认密码." );
FORM1.txtuserPassword1.focus();
return false;
}
if (FORM1.txtuserPassword.value != FORM1.txtuserPassword1.value) {
alert( "两次密码不一致." );
FORM1.txtuserPassword.focus();
return false;
}
str1=FORM1.txtemail.value;
key=str1.match(/\@/);
if (key==null) {
alert( "Email填写错误." );
FORM1.txtemail.focus();
return false;
}
var UnCheck=true;
for (i=0;i<document.FORM1.myfields.length;i++)
{
if (document.FORM1.myfields[i].checked)
{
UnCheck=false;
break;
}
}
if (UnCheck)
{
alert("请选择研究主题.");
document.FORM1.myfields[0].focus();
return false;
}
return true ;
}
//-->
</script>
</head>
<body>
<div align=center>
<form action=userRegisterSave.jsp method=post name=FORM1 onsubmit="checkform()">
<table width="60%" border="0" cellpadding="0" cellspacing="0">
<tr valign="middle">
<td colspan="3" align="center"><br>
<p>
<strong>
<font color="#000099" size=6>公司刊物文章管理系统</font>
</strong>
</p>
</td>
</tr>
<tr>
<td width=50% align=right bgcolor="#DFDFDF">
<font face=Arial,Helvetica color=navy size=3 >用户名:</font>
</td>
<td>
<input type="text" name="txtusername" size="30">
<font color="red">*</font>
</td>
</tr>
<tr>
<td width=50% align=right bgcolor="#DFDFDF">
<font face=Arial,Helvetica color=navy size=3>密码:</font>
</td>
<td >
<input size=30 name="txtuserPassword" type="password">
<font color="red">*</font>
</td>
</tr>
<tr>
<td width=50% align=right bgcolor="#DFDFDF">
<font face=Arial,Helvetica color=navy size=3>确认密码:</font>
</td>
<td>
<input size=30 name="txtuserPassword1" type="password">
<font color="red">*</font>
</tr>
<tr>
<td width=50% align=right bgcolor="#DFDFDF">
<font face=Arial,Helvetica color=navy size=3>姓名:</font>
</td>
<td >
<input size=30 name="txtname" type="text" >
<font color="red">*</font>
</td>
</tr>
<tr>
<td width=50% align=right bgcolor="#DFDFDF">
<font face=Arial,Helvetica color=navy size=3 >所在公司:</font>
</td>
<td>
<input size=30 name="txtcompany" type="text">
</td>
</tr>
<tr>
<td width=50% align=right bgcolor="#DFDFDF">
<font face=Arial,Helvetica color=navy size=3>所属部门:</font>
</td>
<td >
<input size=30 name="txtdepart" type="text">
</td>
</tr>
<tr>
<td width=50% align=right bgcolor="#DFDFDF">
<font face=Arial,Helvetica color=navy size=3>Email:</font>
</td>
<td >
<input type=text size=30 name="txtemail" >
<font color="red">*</font>
</td>
</tr>
<tr>
<td width=50% align=right bgcolor="#DFDFDF">
<font face=Arial,Helvetica color=navy size=3 >研究主题:</font>
</td>
<td>
<%
String strSqlworkgroups="";
Statement stmtworkgroups=dbconn.getConnection().createStatement();
strSqlworkgroups="select * from `workgroup` where tag=0 order by id";
ResultSet rsworkgroups=stmtworkgroups.executeQuery(strSqlworkgroups);
while(rsworkgroups.next())
{
%>
<input type="checkbox" name="txtmyfields" value=<%=rsworkgroups.getLong("ID") %>>
<%=rsworkgroups.getString("note")+' '+rsworkgroups.getString("fieldName")%>
<br>
<%
}
stmtworkgroups.close();
rsworkgroups.close();
%>
</td>
</tr>
<tr>
<td colspan="2">
<font size="3" color="#0000FF">
<center>带<font color="red">*</font>为必填项</center>
</font>
</td>
</tr>
<tr>
<td align=center colspan=2>
<input type=submit value="提交" name="btnSubmit">
      
<input type=reset value="重填" name="btnReset">
</td>
</tr>
</table>
</form>
</div>
</body>
</html>
就是一个用户注册的页面,还有这个页面我如果用IIS的话竟然可以显示出来.另外TOMCAT和JDK都测试过了,数据库我也导入到了MYsql中,完全按说明步骤来的.
回复
KKK2007 2008-04-26
可能是你配置问题
回复
nanjg 2008-04-26
tomcat正常吗?
贴错误异常 或者说明操作步骤
回复
yaray 2008-04-26
请将运行后的错误异常信息和程序源码贴出来看看.
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2008-04-26 10:39
社区公告
暂无公告