<%
}
else
response.sendRedirect("error_login.htm");
}
}
catch(SQLException e) {
}
finally{
try {
if(rs != null) {
rs.close();
rs = null;
}
if(pstmt != null) {
pstmt.close();
pstmt= null;
}
if(conn != null) {
conn.close();
conn = null;
}
}
catch (SQLException e) {
e.printStackTrace();
}
}
%>
5.1.2 个人试题模块的实现
个人试题模块在逻辑层代码如下:
<%@ page language="java" contentType="text/html; charset=gb2312"
pageEncoding="gb2312" import="java.sql.*,com.info.*,com.produce.*"%>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<%
//该页用于修改个人试题
response.setContentType("text/html;charset=gb2312");
request.setCharacterEncoding("gb2312");
Questions aQuestion = new Questions(request.getParameter("serial"));
Answers anAnswer = new Answers(aQuestion.getAnswerId());
String type = request.getParameter("typeSelected");
String isShared = request.getParameter("shared");
//删除
if(request.getParameter("mode").equals("delete")){
aQuestion.deleteQuestion();
anAnswer.deleteAnswer();
%>
<script language="javascript">
alert("删除成功");
javascript:history.go(-1);
</script>
<%
}
%>
<%-- //修改--%>
<%if(request.getParameter("mode").equals("modify")){
int shared = 0;
if(isShared != null)
shared = 1;
aQuestion.setQuestion(request.getParameter("question2"), shared);
if(type.equals("选择题"))
anAnswer.setAnswer(request.getParameter("editA"), request.getParameter("editB"), request.getParameter("editC"), request.getParameter("editD"), request.getParameter("answer"), request.getParameter("remark"));
else
anAnswer.setAnswer(request.getParameter("answer"), request.getParameter("remark"));
%>
<script language="javascript">
alert("修改成功");
javascript:history.go(-1);
</script>
<%
}
%>