さて、私は奇妙な状況にあります。私は基本的に、以前に機能していたこの JSP ページを作成しました。少なくとも、コードを実行したときに表示されるページで Eclipse が新しいタブを開くという意味で。しかし、今日、作成したフォームに戻って確認すると、新しいタブが 1 秒間点滅し、その後自動的に閉じます。コンソールまたは tomcat ログにエラーが記録されていないため、何が起こっているのかわかりません。同じプロジェクトで新しい JSP ファイル (同じコードなし) を作成しようとしたところ、正しく読み込まれました。同様の問題を経験した人はいますか?
以下は私のコードです...
<%@page import="java.sql.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Code Selector</title>
</head>
<body>
<h1>Please select the applicable codes:</h1>
<select name='Code' onchange="showState(this.value)">
<option value="none">Select a code</option>
<%
//Pulls the ids and decriptions from the codes table and stores them in the first drop down
try
{
Class.forName("driverName").newInstance();
Connection con = DriverManager.getConnection("serverURL","username","password");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select id, descr from codes");
while(rs.next())
{
%>
<option value="<%=rs.getString(1)%>"><%=rs.getString(1)%> <%=rs.getString(2)%></option>
<%
}
//Closes the database connection
stmt.close();
con.close();
}
catch (ClassNotFoundException e)
{
System.err.println("ClassNotFoundException: " + e.getMessage());
}
catch (SQLException e)
{
System.err.println("SQLException: " + e.getMessage());
}
catch (Exception e)
{
System.err.println("Generic Exception: " + e.getMessage());
}
%>
</select>
<br>
<br>
<select name='Code2' onchange="showState(this.value)">
<option value="none">Select a code</option>
<%
//Pulls the ids and decriptions from the codes table and stores them in the second drop down
try
{
Class.forName("driverName").newInstance();
Connection con = DriverManager.getConnection("serverURL","username","password");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select id, descr from codes");
while(rs.next())
{
%>
<option value="<%=rs.getString(1)%>"><%=rs.getString(1)%> <%=rs.getString(2)%></option>
<%
}
//Closes the database connection
stmt.close();
con.close();
}
catch (ClassNotFoundException e)
{
System.err.println("ClassNotFoundException: " + e.getMessage());
}
catch (SQLException e)
{
System.err.println("SQLException: " + e.getMessage());
}
catch (Exception e)
{
System.err.println("Generic Exception: " + e.getMessage());
}
%>
</select>
<br>
<br>
<select name='otherCode' onchange="showState(this.value)">
<option value="none">Select a other code</option>
<%
//Pulls the ids and decriptions from the other codes table and stores them in the third drop down
try
{
Class.forName("driverName").newInstance();
Connection con = DriverManager.getConnection("serverURL","username","password");
Statement stmt = con.createStatement();
ResultSet rs2 = stmt.executeQuery("select id, descr from other_codes");
while(rs2.next())
{
%>
<option value="<%=rs2.getString(1)%>"><%=rs2.getString(1)%> <%=rs2.getString(2)%></option>
<%
}
//Closes the database connection
stmt.close();
con.close();
}
catch (ClassNotFoundException e)
{
System.err.println("ClassNotFoundException: " + e.getMessage());
}
catch (SQLException e)
{
System.err.println("SQLException: " + e.getMessage());
}
catch (Exception e)
{
System.err.println("Generic Exception: " + e.getMessage());
}
%>
</select>
<br>
<br>
<form method = "post">
<input type="submit" value="Submit">
<%
try
{
String Code = request.getParameter("Code");
String Code2 = request.getParameter("Code2");
String otherCode = request.getParameter("otherCode");
Class.forName("driverName").newInstance();
Connection con = DriverManager.getConnection("serverURL","username","password");
Statement stmt = con.createStatement();
//ResultSet rs3 = stmt.executeQuery();
System.out.println("This is the first code: " + Code);
System.out.println("This is the second code: " + Code2);
System.out.println("This is the other code: " + otherCode);
con.close();
stmt.close();
}
catch (ClassNotFoundException e)
{
System.err.println("ClassNotFoundException: " + e.getMessage());
}
catch (SQLException e)
{
System.err.println("SQLException: " + e.getMessage());
}
catch (Exception e)
{
System.err.println("Generic Exception: " + e.getMessage());
}
%>
<script>
window.close();
</script>
</form>
</body>
</html>