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

📄 chujuan1_jsp.java

📁 本系统是在线考试系统
💻 JAVA
字号:
package org.apache.jsp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.sql.*;

public final class chujuan1_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {


void randomNum(int a[],int i,int j)
{
 a[i]=1+(int)(Math.random()*j);
for(int c=i-1;c>=0;c--)
    {
	if(a[i]==a[c])
	randomNum(a,i,j);
	}
}

  private static java.util.Vector _jspx_dependants;

  public java.util.List getDependants() {
    return _jspx_dependants;
  }

  public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    JspFactory _jspxFactory = null;
    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;


    try {
      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/html; charset=gb2312");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			"", true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("<SCRIPT language=\"javascript\">\r\n");
      out.write("function backward()\r\n");
      out.write("{\r\n");
      out.write("      history.back();\r\n");
      out.write("}\r\n");
      out.write("function teacher()\r\n");
      out.write("{\r\n");
      out.write("window.location=\"UntitledFrameset-5.htm\";\r\n");
      out.write("}\r\n");
      out.write("</SCRIPT>\r\n");
      out.write("\r\n");
      out.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n");
      out.write("<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n");
      out.write("<head>\r\n");
      out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\" />\r\n");
      out.write("<title>添加成功</title>\r\n");
      out.write("</head>\r\n");
      out.write("\r\n");
      out.write("<body>\r\n");
      out.write('\r');
      out.write('\n');

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String driver = "jdbc:odbc:try";
String user="jsp";
String password="820728";
Connection conn = DriverManager.getConnection(driver,"sa","sa");
Statement stmt = conn.createStatement();
//读取表单内容
int shijuanbianhao=Integer.parseInt(request.getParameter("shijuanbianhao"));
System.out.println('1');
String sql="SELECT * FROM shijuan where shijuanbianhao="+shijuanbianhao;
System.out.println('2');
ResultSet rs=stmt.executeQuery(sql);
System.out.println('3');
if(rs.next())
{
      out.write("\r\n");
      out.write("<p>本试卷编号已经存在,请重新选择填写编号。</p>\r\n");
      out.write("<p><input type=\"button\" name=\"fafa\" value=\"返回上一步\" onclick=\"backward()\"></p>\r\n");
}
else{
int xuanzeshumu=Integer.parseInt(request.getParameter("xuanzeshumu"));
int xuanzefenzhi=Integer.parseInt(request.getParameter("xuanzefenzhi"));
int panduanshumu=Integer.parseInt(request.getParameter("panduanshumu"));
int panduanfenzhi=Integer.parseInt(request.getParameter("panduanfenzhi"));
int zhuguanshumu=Integer.parseInt(request.getParameter("zhuguanshumu"));
int zhuguanfenzhi=0;
int kaoshishijian=Integer.parseInt(request.getParameter("kaoshishijian"));
int i=0;
int j[]=new int [30];
System.out.println('4');
for(i=0;i<xuanzeshumu;i++)
{
  randomNum(j,i,30);
  sql="SELECT * from xuanzeti where id="+j[i];
  rs=stmt.executeQuery(sql);
//  while(rs.next()){
rs.next();
int id=Integer.parseInt(rs.getString("id"));
String timu=rs.getString("tigan");
System.out.println(timu);
String timuleixing="xuanzeti";
String sql1="insert into shijuan values('"+shijuanbianhao+"','"+timu+"','"+xuanzefenzhi+"','"+timuleixing+"','"+id+"','"+kaoshishijian+"')";
stmt.executeUpdate(sql1);
//}
}
System.out.println('5');
for(i=0;i<panduanshumu;i++)
{
randomNum(j,i,20);
 sql="SELECT * from panduanti where id="+j[i];
 rs=stmt.executeQuery(sql);
rs.next();
int id=Integer.parseInt(rs.getString("id"));
String timu=rs.getString("tigan");
String timuleixing="panduanti";
String sql1="insert into shijuan values('"+shijuanbianhao+"','"+timu+"','"+panduanfenzhi+"','"+timuleixing+"','"+id+"','"+kaoshishijian+"')";
stmt.executeUpdate(sql1);
}
System.out.println('6');
for(i=0;i<zhuguanshumu;i++)
{
randomNum(j,i,20);
  sql="SELECT * from zhuguanti where id="+j[i];
  rs=stmt.executeQuery(sql);
//  while(rs.next()){
rs.next();
int id=Integer.parseInt(rs.getString("id"));
String timu=rs.getString("tigan");
String timuleixing="zhuguanti";
zhuguanfenzhi=(100-xuanzefenzhi*xuanzeshumu-panduanfenzhi*panduanshumu)/zhuguanshumu;
String sql1="insert into shijuan values('"+shijuanbianhao+"','"+timu+"','"+zhuguanfenzhi+"','"+timuleixing+"','"+id+"','"+kaoshishijian+"')";
stmt.executeUpdate(sql1);
}
System.out.println('7');
//rs.close();
stmt.close();
conn.close();
System.out.println('8');
}

      out.write("\r\n");
      out.write("<h1>试卷添加成功</h1>\r\n");
      out.write("<p></p>\r\n");
      out.write("</body>\r\n");
      out.write("</html>\r\n");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}

⌨️ 快捷键说明

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