Topic: 我是初学者,JSP问题紧急求助啊!

  Print this page

1.我是初学者,JSP问题紧急求助啊! Copy to clipboard
Posted by: yoyo23mir
Posted on: 2005-05-11 04:33

我是一个JAVA初学者,要写一个JSP查询ACCESS数据库页面,自己写的JSP查询页面执行时,总出现错误页面,提示为:Apache Tomcat/4.04-HTTP Status 500
The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request
图中是我的实际数据库情况,我需要通过输入child_info表中字段cardid的数据来查询define_vac表中字段vacname的数值。三个表的关联如图。哪位好心的哥哥姐姐能帮我写个JSP查询页面代码啊?谢谢了啊!

2.Re:我是初学者,JSP问题紧急求助啊! [Re: yoyo23mir] Copy to clipboard
Posted by: yoyo23mir
Posted on: 2005-05-11 04:34

我自己写了个JSP页面,只是查询child_info表中数据,没有用Beans,执行的时候也是出错。谁能帮我改改啊?

<%@ page contentType="text/html;charset=GB2312" language="java" %>
<%@ page import="java.sql.*" %>
<HTML>
<BODY bgcolor=orange ><Font size=1>
<form action="" Method=post>
请输入查询卡号:
<Input type=text name=number>
<Input type=submit name=g value=查询>
</form>
<%! Connection con=null;//声明一个共享的连接对象。
%>
<% //获取卡号。
String cardid=request.getParameter("number");
if(cardid==null)
{cardid="?";
}
byte b[]=cardid.getBytes("ISO-8859-1");
cardid=new String(b);
Statement sql=null;
ResultSet rs=null;
if(con==null)
{ try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e)
{out.print(e);
}
try {con=DriverManager.getConnection("jdbc:odbc:Vaccard","","");
String condition="SELECT * form child_info WHERE 卡号 = "+"'"+ cardid+"'";
rs =sql.executeQuery(condition);
}
catch(SQLException e)
{out.print(e);
}
}
else
{ synchronized(con)
{ try {sql=con.createStatement();
String condition="SELECT * form child_info WHERE 卡号 = "+"'"+ cardid+"'";
rs =sql.executeQuery(condition);
}
catch(SQLException e)
{out.print(e);
}
}
}
try { out.print("<Table Border>");
out.print("<TR>");
out.print("<TH width=100>"+"卡号");
out.print("<TH width=100>"+"儿童姓名");
out.print("</TR>");
while(rs.next())
{ out.print("<TR>");
String number=rs.getString(1);
out.print("<TD >"+number+"</TD>");
String childname=rs.getString("儿童姓名");
out.print("<TD >"+childname+"</TD>");
out.print("</TR>") ;
}
out.print("</Table>");
}
catch(SQLException e1) {}
%>
</FONT>
</BODY>
</HTML>

3.Re:我是初学者,JSP问题紧急求助啊! [Re: yoyo23mir] Copy to clipboard
Posted by: why
Posted on: 2005-05-11 10:49

1. try something simpler first
2. I don't think it's a good idea to name fields in Chinese
3. do use Beans instead of writing spaghetti code like this
4. follow XHTML style when writing HTML tags, i.e. lowercase, value with quotes, etc.

4.Re:我是初学者,JSP问题紧急求助啊! [Re: yoyo23mir] Copy to clipboard
Posted by: yoyo23mir
Posted on: 2005-05-11 14:09

没人帮忙啊?

5.Re:我是初学者,JSP问题紧急求助啊! [Re: yoyo23mir] Copy to clipboard
Posted by: why
Posted on: 2005-05-12 21:34

yoyo23mir wrote:
没人帮忙啊?

Did you mean I am not a 人 or I was not 帮忙?Big Smile
What do you expect?
I really don't want to touch your messy piece of code. I had enough.Dead

6.Re:我是初学者,JSP问题紧急求助啊! [Re: yoyo23mir] Copy to clipboard
Posted by: computerclass
Posted on: 2005-05-13 23:08

我是初学者,想帮你,但无能为力,WHY说的有一定道理。
先化简为易,首先看能否连上数据库,再试试其他的操作。

7.Re:我是初学者,JSP问题紧急求助啊! [Re: yoyo23mir] Copy to clipboard
Posted by: mhlovers
Posted on: 2005-06-29 11:51

要一步一步的来!
从整体到细节!


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923