response.setContentType("text/html;charset=8859_1");
PrintWriter out = response.getWriter();
try {
String sid = request.getParameter("sid");
int intsid = Integer.parseInt(sid);
Student student = facade.findStudent(intsid);
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet selectCourse</title>");
out.println("</head>");
out.println("<body>");
out.println("<a>Welcome!Student Name:"+student.getInfo().getName()+"</a>");
List<Course> courses = facade.findAllCourse();
out.println("<h2>Want to Select Course?</h2>");
List<Course> selectedCourses = new ArrayList<Course>();
selectedCourses = student.getCourses();
{
out.println("</ol>");
for (Course course : courses) {
if (selectedCourses==null || !selectedCourses.contains(course)){
out.println("<li>Course name:");
out.println("Click Here to Select "+course.getCname()+" from selectCourse ");
out.println("<a href=\"CourseSelect?cid="+course.getCid()+"&sid="+student.getId()+"\">Select This Course</a>");
out.println("</li>");
}
}
out.println("</ol>");
}
out.println("<h2>Want to Cancel selected Course?</h2>");
if(student.getCourses()==null){
out.println("<p>INFO:Student has no course selected.</p>");
}
else
{
selectedCourses = student.getCourses();
out.println("<ol>");
for (Course course : selectedCourses) {
out.println("<li>Course name:");
out.println("Click Here to Unselect "+course.getCname()+" from selectCourse");
out.println("<a href=\"CourseUnselect?cid="+course.getCid()+"&sid="+student.getId()+"\">Unselect This Course</a>");
out.println("</li>");
}
out.println("</ol>");
}