⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 check.jsp~104~

📁 system1为用户注册模块 system2为在线聊天系统 system3为在线投票系统 system4为在线考试系统 system5为新闻发布模块
💻 JSP~104~
字号:
<%@ page contentType="text/html; charset=gb2312"  language="java" errorPage=""%>
<%@ page import="java.sql.*" %>
<jsp:useBean id="sqltest" class="database.sqlbean" scope="page">
</jsp:useBean>
<html>
<head>
<title>在线答题</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="0">
</head>
<body>
  <form action = thanks.jsp method="post">
<%
  String permit;
  ResultSet rs=null;
  ResultSet ch_rs=null;
  String SqlString="SELECT Question,QuestionID from questions where IsVisable = 1";
try
  {
    //设置连接
    sqltest.setConnection("com.microsoft.jdbc.sqlserver.SQLServerDriver","jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=questionnaire","sa","");
    //设置SQL语句
    sqltest.setQuerystatement(SqlString);
    //得到查询结果
    rs=sqltest.getResult();
    int questionid = 0,itemid = 0;
    int i=0,j; //题目及选项标号
    while(rs.next())
    {
       i++;
      String question = rs.getString(1);
      questionid= rs.getInt(2);
      out.print("<TABLE borderColor=#999999 cellSpacing=0 cellPadding=0 width=100% border=0><tr bgcolor=#999999><td>"+" "+i+"."+" "+question+"</td></tr>");

      String ch_sql = "SELECT Item,ItemID From Items Where QuestionID ='"+questionid+"'";
      sqltest.setQuerystatement(ch_sql);
      ch_rs=sqltest.getResult();
      j = 0;
      while(ch_rs.next())
      {
        j++;
	String item = ch_rs.getString(1);
        itemid = ch_rs.getInt(2);
        %>
	 <td >
           <%=j%><input type=radio value="<%=itemid%>" name="<%=questionid%>"><%=item%>
         </td></tr>
      <%
      }
      out.print(" </table><p>");
     }
  }
    catch(SQLException e1)
  {
    out.print("SQL异常!");
  }

%>
          <hr>
          <DIV align=center><INPUT class=buttonface type=submit value=提交 name=Submit>
<INPUT class=buttonface type=reset value=重选 name=Submit2>
          </div>
</form>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -