源文件代码:
<%@ page import="java.util.Date,java.lang.*" %>
<%@ page import="java.util.Calendar" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.text.*" %>
<%@ page import="java.lang.Integer" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 2003">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>提交</title>
</head>
<body>
<table align="left">
<%
String QType="";
int answer=0;
int i=0;
byte[] tmpbyte;
String ctemp;
String CColor;
Connection conn=null;
Statement stmt;
ResultSet rs=null;
String[] Context=request.getParameterValues("Context");
String[] KeyA=request.getParameterValues("KeyA");
String[] KeyB=request.getParameterValues("KeyB");
String[] KeyC=request.getParameterValues("KeyC");
String[] KeyD=request.getParameterValues("KeyD");
String[] KeyE=request.getParameterValues("KeyE");
if (Context[0].equals(""))
{
out.print("<div align=\"center\">\n");
out.print("<center>");
out.print("<table border=\"1\" cellspacing=\"0\" width=\"288\" height=\"153\" cellpadding
=\"0\" bordercolordark=\"#FFFFFF\" bordercolorlight=\"#000000\">\n");
out.print("<tr>");
out.print("<td width=\"280\" align=\"center\" height=\"18\" bgcolor=\"#C0C0C0\">注意</td>\n");
out.print("</tr>");
out.print("<tr>\n");
out.print("<td width=\"280\" align=\"center\" height=\"127\">\n");
out.print("<div align=\"left\">\n");
out.print("<table border=\"0\" cellspacing=\"1\" width=\"101%\" height=\"86\">\n");
out.print("<tr>\n");
out.print("<td width=\"100%\" align=\"center\" height=\"18\"></td>\n");
out.print("</tr>\n");
out.print("<tr>\n");
out.print("<td width=\"100%\" align=\"center\" height=\"16\">题目内容不能为空!!</td>\n");
out.print("</tr>\n");
out.print("<tr>\n");
out.print("<td width=\"100%\" align=\"center\" height=\"18\"></td>\n");
out.print("</tr>\n");
out.print("<tr>\n");
out.print("<td width=\"100%\" align=\"center\" height=\"18\">
<input type=\"button\" OnClick=\"JavaScript:history.back()\" value="返回\"></td>\n");
out.print("</tr>\n");
out.print("</table>\n");
out.print("</div>\n");
out.print("</td>\n");
out.print("</tr>\n");
out.print("</table>\n");
out.print("</center>\n");
out.print("</div>\n");
}
else
{
answer=0;
if(KeyA!=null)
{
answer=answer+10000;
i=i+1;
}
if(KeyB!=null)
{
answer=answer+1000;
i=i+1;
}
if(KeyC!=null)
{
answer=answer+100;
i=i+1;
}
if(KeyD!=null)
{
answer=answer+10;
i=i+1;
}
if(KeyE!=null)
{
answer=answer+1;
i=i+1;
}
if(i==0)
{
out.print("<div align="\center\">\n");
out.print("<center>");
out.print("<table border=\"1\" cellspacing=\"0\" width=\"288\" height=\"153\"
cellpadding=\"0\" bordercolordark=\"#FFFFFF\" bordercolorlight=\"#000000\">\n");
out.print("<tr>");
out.print("<td width=\"280\" align=\"center\" height=\"18\" bgcolor=\"#C0C0C0\">注意</td>\n");
out.print("</tr>");
out.print("<tr>\n");
out.print("<td width=\"280\" align=\"center\" height=\"127\">\n");
out.print("<div align="\left\">\n");
out.print("<table border=\"0\" cellspacing=\"1\" width=\"101%\" height=\"86\">\n");
out.print("<tr>\n");
out.print("<td width=\"100%\" align=\"center\" height=\"18\"></td>\n");
out.print("</tr>\n");
out.print("<tr>\n");
out.print("<td width=\"100%\" align=\"center\" height=\"16\">没有答案!</td>\n");
out.print("</tr>\n");
out.print("<tr>\n");
out.print("<td width=\"100%\" align=\"center\" height=\"18\"></td>\n");
out.print("</tr>\n");
out.print("<tr>\n");
out.print("<td width=\"100%\" align=\"center\" height=\"18\"><input type=\"button\"
OnClick=\"JavaScript:history.back()\" value=\"返回\"></td>\n");
out.print("</tr>\n");
out.print("</table>\n");
out.print("</div>");
out.print("</td>");
out.print("</tr>\n");
out.print("</table>\n");
out.print("</center>\n");
out.print("</div>\n");
}
else
{
QType="T";
if(i>1)
{
QType="N";
}
tmpbyte=Context[0].getBytes("ISO8859_1");
ctemp=new String(tmpbyte,"GBK");
String t1=Integer.toString(answer);
String t2=Integer.toString(i);
try{
String sql="Insert Into question(Context,Key,Type) VALUES('"+ctemp+"',"+t1+",'"+QType+"')";
String url="jdbc:odbc:test";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn=DriverManager.getConnection(url);
stmt=conn.createStatement();
stmt.execute(sql);
out.print("<div align="\center\">\n");
out.print("</center>");
out.print("<table border=\"1\" cellspacing=\"0\" width=\"288\" height=\"153\"
cellpadding=\"0\" bordercolordark=\"#FFFFFF\" bordercolorlight=\"#000000\">\n");
out.print("<tr>");
out.print("<td width=\"280\" align=\"center\" height=\"18\" bgcolor=\"#C0C0C0\">注意</td>\n");
out.print("</tr>");
out.print("<tr>\n");
out.print("<td width=\"280\" align=\"center\" height=\"127\">\n");
out.print("<div align="\left\">\n");
out.print("<table border=\"0\" cellspacing=\"1\" width=\"101%\" height=\"86\">\n");
out.print("<tr>\n");
out.print("<td width=\"100%\" align=\"center\" height=\"18\"></td>\n");
out.print("</tr>\n");
out.print("<tr>\n");
out.print("<td width=\"100%\" align=\"center\" height=\"16\">正确添加!!</td>\n");
out.print("</tr>\n");
out.print("<tr>\n");
out.print("<td width=\"100%\" align=\"center\" height=\"18\"></td>\n");
out.print("</tr>\n");
out.print("<tr>\n");
out.print("<td width=\"100%\" align=\"center\" height=\"18\">
<a href=\"input.html\">继续</a> </td>\n");
out.print("</tr>\n");
out.print("</table>\n");
out.print("</div>");
out.print("</td>");
out.print("</tr>\n");
out.print("</table>\n");
out.print("</center>\n");
out.print("</div>\n");
}catch(SQLException ex)
{
tmpbyte=ex.getMessage().getBytes("GBK");
ctemp=new String(tmpbyte,"ISO8859_1");
out.print(ctemp);
}
}
}
%>
</table>
</body>
</html>