use of Model.Courses in project Happourse_online_study_web by infiq2000.
the class CourseByCategory method doGet.
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
int cid = Integer.parseInt(request.getParameter("cid"));
try {
List<Courses> courses = couUtil.getCourseByCategory(cid);
request.setAttribute("listCourses", courses);
RequestDispatcher dispatcher = request.getRequestDispatcher("/UserPage.jsp");
dispatcher.forward(request, response);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of Model.Courses in project Happourse_online_study_web by infiq2000.
the class Login method doPost.
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String userName = request.getParameter("username");
String passWord = request.getParameter("password");
try {
User user = null;
Account tmp = accUtil.validation(userName, passWord);
if (tmp != null) {
if (!tmp.isType()) {
user = userUtil.getUser(tmp.getAid());
List<Courses> courses = userUtil.getAll_Courses();
request.setAttribute("listCourses", courses);
request.setAttribute("user_info", user);
String[] a = user.getFull_name().split(" ");
String b = a[a.length - 1];
HttpSession session = request.getSession(true);
session.setAttribute("name", b);
session.setAttribute("uid", user.getUid());
session.setAttribute("aid", user.getAid());
RequestDispatcher dispatcher = request.getRequestDispatcher("/UserPage.jsp");
dispatcher.forward(request, response);
}
} else {
request.setAttribute("errorString", "Username or password is incorrect");
RequestDispatcher dispatcher = request.getRequestDispatcher("/invalidLogin.jsp");
dispatcher.forward(request, response);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of Model.Courses 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.Courses 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.Courses in project Happourse_online_study_web by infiq2000.
the class SearchCoursesByName method doGet.
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String txtSearch = request.getParameter("search");
// txtSearch = txtS.toLowerCase();
List<Courses> courses = null;
try {
courses = couUtil.searchCourseByName(txtSearch);
} catch (Exception e) {
System.out.println(e);
}
request.setAttribute("listCourses", courses);
RequestDispatcher dispatcher = request.getRequestDispatcher("/UserPage.jsp");
dispatcher.forward(request, response);
}
Aggregations