Integer userID;
userID = Integer.valueOf(request.getParameter("userID"));
// First generate a array list with maps containing courseIDs and their descriptions
CoursesJpaController coursesJpaController = new CoursesJpaController();
List<Integer> searchedCourseIDList;
SearchBean bean = new SearchBean();
searchedCourseIDList = bean.getSearchedCoursesForSearchKeyAndUserID(key, userID);
//********************************
// Second generate an ArrayList consist of course objects
ArrayList coursesMapList = new ArrayList();
for (Iterator<Integer> it = searchedCourseIDList.iterator(); it.hasNext();) {
Integer courseID = it.next();
Courses course = coursesJpaController.findCourses(courseID);
Map courseMap = new HashMap();
courseMap.put("courseID", new Integer(course.getCourseId()));
courseMap.put("courseName", new String(course.getName()));
coursesMapList.add(courseMap);