use of Model.Chapter in project Happourse_online_study_web by infiq2000.
the class CourseDetail method doGet.
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
int course_id = Integer.parseInt(request.getParameter("course_id"));
int uid = (int) request.getSession(false).getAttribute("uid");
int aid = (int) request.getSession(false).getAttribute("aid");
try {
/* Account ac = accUtil.getAccount(aid); */
Account acc = accUtil.getAccount(aid);
request.setAttribute("account", acc);
request.setAttribute("course_id", course_id);
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
Courses detailC = courseUtil.getCourseDetail(course_id);
request.setAttribute("course_detail", detailC);
String cate = insUtil.getCate(detailC.getCid());
request.setAttribute("cate", cate);
Instructor ins_info = insUtil.getIns_Info(detailC.getIns_id());
request.setAttribute("ins_info", ins_info);
List<Chapter> list_chapter = lecUtil.getChapterOfCourse(detailC.getCourses_id());
request.setAttribute("chapter", list_chapter);
RequestDispatcher dispatcher;
if (courseUtil.checkSignedCourse(course_id, uid) == null) {
dispatcher = request.getRequestDispatcher("/Course_detail.jsp");
} else {
dispatcher = request.getRequestDispatcher("/CourseSigned.jsp");
}
dispatcher.forward(request, response);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of Model.Chapter in project Happourse_online_study_web by infiq2000.
the class RemoveCourse method doGet.
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
int course_id = Integer.parseInt(request.getParameter("course_id"));
int uid = (int) request.getSession(false).getAttribute("uid");
request.setAttribute("course_id", course_id);
try {
Courses detailC = courseUtil.getCourseDetail(course_id);
request.setAttribute("course_detail", detailC);
String cate = insUtil.getCate(detailC.getCid());
request.setAttribute("cate", cate);
Instructor ins_info = insUtil.getIns_Info(detailC.getIns_id());
request.setAttribute("ins_info", ins_info);
List<Chapter> list_chapter = lecUtil.getChapterOfCourse(detailC.getCourses_id());
request.setAttribute("chapter", list_chapter);
courseUtil.removeCourse(uid, course_id);
RequestDispatcher dispatcher = request.getRequestDispatcher("/Course_detail.jsp");
dispatcher.forward(request, response);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of Model.Chapter in project Happourse_online_study_web by infiq2000.
the class LectureUtil method getChapterOfCourse.
public List<Chapter> getChapterOfCourse(int course_id) throws SQLException {
Connection myConn = null;
PreparedStatement myStmt = null;
ResultSet myRS = null;
myConn = dataSource.getConnection();
String sql = "select * from chapter where course_id = ? ";
myStmt = myConn.prepareStatement(sql);
myStmt.setInt(1, course_id);
myRS = myStmt.executeQuery();
List<Chapter> chapter = new ArrayList<>();
int dem = 0;
while (myRS.next()) {
dem++;
int chap_id = myRS.getInt("chap_id");
String name = myRS.getString("name");
chapter.add(new Chapter(chap_id, name, course_id));
}
System.out.println(dem);
return chapter;
}
Aggregations