📄 savedata_jsp.java
字号:
package org.apache.jsp.admin;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.sql.*;
import java.util.*;
public final class savedata_jsp extends org.apache.jasper.runtime.HttpJspBase
implements org.apache.jasper.runtime.JspSourceDependent {
String convert(String str)
{
byte newstr[] = new byte[str.length()];
for(int i=0;i<str.length();i++)
newstr[i]=(byte)str.charAt(i);
return new String(newstr);
}
String Replace(String str)
{
int index=0;
while((index=str.indexOf("\n")) != -1)
str = str.substring(0,index) +"<br>"+ str.substring(index+1);
return(str);
}
String sqlstring;
ResultSet rs=null;
int isempty(String str) //判断递交的字符串是否为空
{
if(str.length() ==0)
return (0);
else return (1);
}
String transfer(int i) //将时间数值转换为标准格式
{
if(i>=10)
return (String.valueOf(i));
else return ("0"+String.valueOf(i));
}
private static java.util.Vector _jspx_dependants;
static {
_jspx_dependants = new java.util.Vector(2);
_jspx_dependants.add("/admin/convert.jsp");
_jspx_dependants.add("/admin/check.jsp");
}
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,
null, 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");
out.write("\r\n");
out.write('\r');
out.write('\n');
out.write('\r');
out.write('\n');
//ÑéÖ¤¹ÜÀíÔ±ÊÇ·ñÒѾµÇ½
if((String)session.getValue("Enter")!="true")
{
String errmsg="error2";
response.sendRedirect("login.jsp?errmsg="+errmsg);
}
out.write('\r');
out.write('\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');
out.write('\n');
out.write('\r');
out.write('\n');
out.write('\r');
out.write('\n');
String question = request.getParameter("question");
String item[] = {request.getParameter("item1"),request.getParameter("item2"),
request.getParameter("item3"),request.getParameter("item4"),
request.getParameter("item5"),request.getParameter("item6"),
request.getParameter("item7"),request.getParameter("item8"),
request.getParameter("item9"),request.getParameter("item0"),};
if((isempty(item[0])+isempty(item[1])+isempty(item[2])+isempty(item[3])+
isempty(item[4])+isempty(item[5])+isempty(item[6])+isempty(item[7])+
isempty(item[8])+isempty(item[9]))==0)
{
String errmsg = "选项不得全部为空!!!";
out.print("<center><font color=green size=5>错误信息<hr></font><font color=red>"+errmsg+"</font><hr>");
out.print("<input type=button value=回上一页 onclick=history.back()>");
}
else if((isempty(item[0])+isempty(item[1])+isempty(item[2])+isempty(item[3])+
isempty(item[4])+isempty(item[5])+isempty(item[6])+isempty(item[7])+
isempty(item[8])+isempty(item[9]))<2)
{
String errmsg = "选项至少为两个!!!";
out.print("<center><font color=green size=5>错误信息<hr></font><font color=red>"+errmsg+"</font><hr>");
out.print("<input type=button value=回上一页 onclick=history.back()>");
}
else if(question.length()==0)
{
String errmsg = "问题不可为空!!!";
out.print("<center><font color=green size=5>错误信息<hr></font><font color=red>"+errmsg+"</font><hr>");
out.print("<input type=button value=回上一页 onclick=history.back()>");
}
else
{
int year,month,day,hour,minute,second;
String time;
GregorianCalendar calendar;
calendar = new GregorianCalendar();
year = calendar.get(Calendar.YEAR);
month = calendar.get(Calendar.MONTH)+1;
day = calendar.get(Calendar.DAY_OF_MONTH);
hour = calendar.get(Calendar.HOUR_OF_DAY);
minute = calendar.get(Calendar.MINUTE);
second = calendar.get(Calendar.SECOND);
time = year +"-"+transfer(month)+"-" + transfer(day) +" "+transfer(hour)+":"+transfer(minute)+":"+transfer(second);
sqlstring = "insert into Questions(Question,Date) values('"+question+"','"+time+"')";
sqltest.executeUpdate(sqlstring);
sqlstring = "select QuestionID from Questions where Date= '"+time+"'";//利用新建立的时间查找新建立的题目的ID号
rs = sqltest.executeQuery(sqlstring);
int questionid = 0;
// rs.beforeFirst();
while(rs.next())
{
questionid = rs.getInt(1);
}
for(int i = 0;i<=9;i++)
{
if(isempty(item[i])==1)
{
sqlstring = "insert into Items(Item,QuestionID) values('"+item[i]+"','"+questionid+"')";
sqltest.executeUpdate(sqlstring);
}
}
response.sendRedirect("mainform.jsp");
}
out.write("\r\n");
out.write("<html>\r\n");
out.write("<title>错误信息</title>\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 + -