📄 showquestion_jsp.java
字号:
package org.apache.jsp;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.sql.*;
public final class showquestion_jsp extends org.apache.jasper.runtime.HttpJspBase
implements org.apache.jasper.runtime.JspSourceDependent {
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("\r\n");
out.write("\r\n");
database.opendata sqltest = null;
synchronized (_jspx_page_context) {
sqltest = (database.opendata) _jspx_page_context.getAttribute("sqltest", PageContext.PAGE_SCOPE);
if (sqltest == null){
sqltest = new database.opendata();
_jspx_page_context.setAttribute("sqltest", sqltest, PageContext.PAGE_SCOPE);
out.write('\r');
out.write('\n');
}
}
out.write("\r\n");
out.write("<html>\r\n");
out.write("<head>\r\n");
out.write("<title>在线答题</title>\r\n");
out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">\r\n");
out.write("<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\r\n");
out.write("<META HTTP-EQUIV=\"Cache-Control\" CONTENT=\"no-cache\">\r\n");
out.write("<META HTTP-EQUIV=\"Expires\" CONTENT=\"0\">\r\n");
out.write("</head>\r\n");
out.write("<body>\r\n");
out.write(" <form action = thanks.jsp method=\"post\">\r\n");
String permit;
String SqlString="SELECT Question,QuestionID from questions where IsVisable = 1";
try
{
ResultSet rs=null;
ResultSet ch_rs=null;
//设置连接
// sqltest.setConnection("com.microsoft.jdbc.sqlserver.SQLServerDriver","jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=questionnaire","sa","");
//设置SQL语句
rs=sqltest.executeQuery(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();
ch_rs=sqltest.executeQuery(ch_sql);
j = 0;
while(ch_rs.next())
{
j++;
String item = ch_rs.getString(1);
itemid = ch_rs.getInt(2);
out.write("\r\n");
out.write("\t <td >\r\n");
out.write(" ");
out.print(j);
out.write("<input type=radio value=\"");
out.print(itemid);
out.write("\" name=\"");
out.print(questionid);
out.write('"');
out.write('>');
out.print(item);
out.write("\r\n");
out.write(" </td></tr>\r\n");
out.write(" ");
}
out.print(" </table><p>");
}
}
catch(SQLException e1)
{
out.print("SQL异常!");
}
out.write("\r\n");
out.write(" <hr>\r\n");
out.write(" <DIV align=center><INPUT class=buttonface type=submit value=提交 name=Submit>\r\n");
out.write("<INPUT class=buttonface type=reset value=重选 name=Submit2>\r\n");
out.write(" </div>\r\n");
out.write("</form>\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 + -