单独使用IE浏览器不能在其中以网页的形式显示,只显示代码。请问大侠是什么问题?——急
现将代码附如下:
<%@ page contentType="text/html; charset=gb2312" %>
<%@ page import="java.io.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.util.*"%>
<!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=gb2312">
<title>网络考试系统--欢迎您进入考试页面</title>
<link href="img/style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
background-image: url(img/bg.GIF);
}
-->
</style></head>
<jsp:useBean id="execsql" class="xxx.execsql" scope="page">
</jsp:useBean>
<body>
<table width="47" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="47">
<form name="forms">
<input type=text name=input1 size=9><script language=javascript><!--
var sec=0;var min=0;var hou=0;flag=0;idt=window.setTimeout("update();",1000);
function update(){sec++;if(sec==60){sec=0;min+=1;}if(min==60){min=0;hou+=1;}if((min>0)&&(flag==0)){flag=1;}
document.forms.input1.value=hou+"时"+min+"分"+sec+"秒";idt=window.setTimeout("update();",1000);}
//-->
</script>
</form>
</td>
</tr>
</table>
<%
int n=0;//获得ctrl_test表的num字段的值,并将其加一,用来记录登录的人数
String str1=String.valueOf(n);
ResultSet rs0=execsql.RS("select * from ctrl_test");
if (rs0.next()){
n=rs0.getInt("num");
n=n+1;
str1=String.valueOf(n);}
execsql.UP("update ctrl_test set num="+str1);
String ip_addr=request.getRemoteAddr(); //获取客户机的IP地址
int course_id=Integer.parseInt(request.getParameter("course_id"));
int tea_id=Integer.parseInt(request.getParameter("tea_id"));
int test_id=Integer.parseInt(request.getParameter("test_id"));
String stu_id=request.getParameter("stu_id");
out.println("你是第"+str1+"位考生 你的IP地址为"+ip_addr+" 学号为"+stu_id);
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:test";
Connection con=DriverManager.getConnection(url,"sa","");
Statement stmt=con.createStatement();
String sql="select count(*) as count from v_test_sel where test_id="+test_id+" and tea_id="+tea_id+" and course_id="+course_id;
String sql1="insert into remoteaddress(remoteaddress,stu_id) values('"+ip_addr+"','"+stu_id+"')";
stmt.executeUpdate(sql1);//将用户的IP地址,用户学号,用户名写入数据库表remoteaddress
ResultSet rs1=stmt.executeQuery(sql);
rs1.next();
int count=rs1.getInt("count");
rs1.close();
ResultSet rs=stmt.executeQuery("select*from v_test_sel where test_id="+test_id+" and tea_id="+tea_id+" and course_id="+course_id);
%>
<h3><strong>一、选择题</strong></h3>
<center>
<form name="form" method="post" action="result.jsp">
<input type="hidden" name="count" value="<%=count%>">
<%
int i=0;
while(rs.next())
{
%>
<table width="760" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>第<%=i+1%>题:<font color="#ff6600"><strong><%=rs.getString("sel_item")%></strong> </font></td>
</tr>
</table>
<br>
<table width="760" border="1" align="center" cellpadding="1" cellspacing="0" bordercolor="#FFFFFF">
<tr>
<td width="146" bordercolor="#CCCCCC">A:
<input type="radio" name="ra<%=i%>" value="a">
<%=rs.getString("a")%><br> </td>
<td width="174" bordercolor="#CCCCCC">B:
<input type="radio" name="ra<%=i%>" value="b">
<%=rs.getString("b")%><br></td>
<td width="204" bordercolor="#CCCCCC">C:
<input type="radio" name="ra<%=i%>" value="c">
<%=rs.getString("c")%><br></td>
<td width="218" bordercolor="#CCCCCC">D:
<input type="radio" name="ra<%=i%>" value="d">
<%=rs.getString("d")%></td>
</tr>
</table>
<table width="760" height="132" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="343" height="18" colspan="2"> <div align="left">
<tr>
<td width="570" height="28"><div align="left">
<%
i++;
}
rs.close();
%>
<hr><strong><h3>二、填空题</h3></strong>
<!--下面代码是简答题的代码-->
<%
ResultSet rs_scount=stmt.executeQuery("select count(*) as scount from v_test_ans where test_id="+test_id+" and tea_id="+tea_id+" and course_id="+course_id);
rs_scount.next();
int scount=rs_scount.getInt("scount");
rs_scount.close();
ResultSet rs2=stmt.executeQuery("select*from v_test_ans where test_id="+test_id+" and tea_id="+tea_id+" and course_id="+course_id);
int s_i=0;
while(rs2.next())
{
%>
第<%=s_i+1%>题:
<%
int ans_id=rs2.getInt("ans_id");
String ans_item=rs2.getString("ans_item");
String diff=rs2.getString("s_a").trim();
String answer=rs2.getString("answer");
if(diff.equals("1")){
out.print("<strong><填空题></strong>");
out.print(ans_item+"<br>");
%>
<input name="stu_ans<%=s_i%>" type="text" size="80">
<br><br>
<%
}
else{
out.print("<strong><问答题></strong>");
out.print(ans_item+"<br>");
%>
</div></td>
</tr>
<tr>
<td><div align="left">
<textarea rows="5" cols="80" name="stu_ans<%=s_i%>"></textarea>
</div></td><br><br>
</tr>
<tr>
<td><div align="left">
<%}%>
<input type="hidden" name="ans_id<%=s_i%>" value="<%=ans_id%>">
<input type="hidden" name="ans_item<%=s_i%>" value="<%=ans_item%>">
<input type="hidden" name="answer<%=s_i%>" value="<%=answer%>">
<input type="hidden" name="diff<%=s_i%>" value="<%=diff%>">
<%
s_i++;
}
rs2.close();
%>
<input type="hidden" name="scount" value="<%=scount%>">
<input type="hidden" name="stu_id" value="<%=stu_id%>">
<input type="hidden" name="tea_id" value="<%=tea_id%>">
<input type="hidden" name="course_id" value="<%=course_id%>">
<input type="hidden" name="test_id" value="<%=test_id%>"> <br>
<input type="submit" name="submit" value="提交">
</div></td>
</tr>
</table>
<div align="left"><br>
</div>
</form>
</center>
</body>
</html>
问题点数:20、回复次数:0Top




