重要なお知らせ

「教えて! goo」は2025年9月17日(水)をもちまして、サービスを終了いたします。詳細はこちら>

電子書籍の厳選無料作品が豊富!

<%@ page contentType="text/html; charset=Shift_JIS" %>
<%@ page import="java.sql.*,javahello.DBConnectionPool" %>
<%!
DBConnectionPool pool;
%>
<%
Connection con = null;
Statement stmt = null;
try {
// コネクションプールクラスのインスタンスを取得
pool = DBConnectionPool.getInstance();
// データベースへの接続を取得
con = pool.getConnection();
// ステートメントオブジェクトを生成
stmt = con.createStatement();
// 全ての行を検索するSQL文を作成
String sql = "SELECT * FROM SHAINLIST";
ResultSet rs = stmt.executeQuery(sql);
// 一覧表示用テーブル
String tableL = "<table border=1>";
tableL +="<tr bgcolor=\"000080\"><td>
<font color=\"white\">ID</font></td>"
+ "<"td nowrap><font color =\"white\">名前</font></td>"
+ "<"td colspan = 2><font color=\"white\"出欠</font></td></tr>";
// 取得結果の処理
while(rs.next()) {
int id = rs.getInt("member_id");
String name = rs.getString("name");
int state = rs.getInt("attendance");
String comment = rs.getString("comment");
String cell1;
String cell2;
switch(state) {
case -1://欠席
cell1 = "<font color=\"red\"><b>欠席</b></font>";
cell2 = "<br> + comment +"<br><br>";
break;

case 1://出席
cell1 = "<font color=\"blue\"><b>出席</b></font>";
cell2 = "<br>" + comment + "<br><br>";

default://未定
cell1 = "<b>未定</b>";
cell2 = "<form action=\"sub.jsp\">"
+ "<input type=\"hidden\" name=\"member_id\" value=\"" + id + "\">"

+ "<input type=\"radio\" value=\"1\" checked name=\"attendance\">出席"
+ "<input type=\"radio\" value=\"-1\" name=\"attendance\">欠席<br>"
+ "<input type=\"text\" name=\"comment\" size=36> "
+ "<input type=\"submit\" value=\"登録\"></form>";
}

// テーブル用
tableL += "<tr><td align=\right" bgcolor=\"A0A0A0\"><b>"+id+"</b></td>"
+ "<td nowrap>" + name + "</td><td>" + cell1 + "</td><td>"
+ cell2 + "</td></tr>";
}
tableL += "</table>";
db.close();
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><title>データベースへのアクセス</title></head>
<body>
<p>-- データベースへのアクセス --</p>
<p>
<b>新人歓迎会 出欠状況一覧</b><br>
<%= tableHTML %>
</p>
</body>
</html>

まちがってるところ
がみつからないですが。。みなさん助けてくださいmm
よろしくお願いします。

A 回答 (1件)

問題の丸投げはネチケット違反ですよ。


ソースコードをいきなり貼り付けられても困ります。

そもそも、何がどのように期待通り動いていないのか、
予想結果と実行結果の相違点はなんなのか教えてもらわないと、
解りません。

気になる点:
+ "<"td colspan = 2><font color=\"white\"出欠</font></td></tr>";

+ "<"td colspan = 2><font color=\"white\">出欠</font></td></tr>";
か?
    • good
    • 0
この回答へのお礼

すみません。初心者なので、
tomcatを使って、ウェブで表示したいですが、エラーメッセージの意味がわからなくて。。。ここで質問してしまいました。
失礼しました。

お礼日時:2007/04/17 22:38

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!