Advertisement
naelah

Lab 7: scheduleServlet

May 2nd, 2014
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.79 KB | None | 0 0
  1. package my.edu.iium.webprogramming;
  2.  
  3. import java.io.IOException;
  4. import javax.servlet.ServletException;
  5. import javax.servlet.annotation.WebServlet;
  6. import javax.servlet.http.HttpServlet;
  7. import javax.servlet.http.HttpServletRequest;
  8. import javax.servlet.http.HttpServletResponse;
  9. import javax.servlet.http.HttpSession;
  10.  
  11.  
  12. /**
  13. * Servlet implementation class scheduleServlet
  14. */
  15. @WebServlet("/scheduleServlet")
  16. public class scheduleServlet extends HttpServlet {
  17. private static final long serialVersionUID = 1L;
  18.  
  19. /**
  20. * @see HttpServlet#HttpServlet()
  21. */
  22. public scheduleServlet() {
  23. super();
  24. // TODO Auto-generated constructor stub
  25. }
  26.  
  27. /**
  28. * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
  29. */
  30. protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  31. // TODO Auto-generated method stub
  32. course c1 = new course();
  33. c1.setCourseCode("CSC2201");
  34. c1.setCourseName("Computer Networks");
  35. c1.setInstructor("Dr. Zul");
  36. c1.setStartTime("2.00 pm");
  37. c1.setEndTime("3.00 pm");
  38.  
  39. course c2 = new course();
  40. c2.setCourseCode("CSC2202");
  41. c2.setCourseName("Advanced Computer Networks");
  42. c2.setInstructor("Dr. Zul");
  43. c2.setStartTime("2.00 pm");
  44. c2.setEndTime("3.00 pm");
  45.  
  46. schedule s = new schedule();
  47. s.setSem("1");
  48. s.setYear("2012");
  49. s.addCourse(c1);
  50. s.addCourse(c2);  
  51. HttpSession session = request.getSession(true);
  52. session.setAttribute("currentSessionSchedule",s);
  53. response.sendRedirect("scheduleview.jsp");
  54.  
  55. System.out.println(s.getCourses());
  56. }
  57.  
  58. /**
  59. * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
  60. */
  61. protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  62. // TODO Auto-generated method stub
  63. }
  64.  
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement