I have a dropdown menu and i want when selecting an item from menu just to show it below. This is my jsp:
<body>
<select name="courseSelect">
<c:forEach var="course" items="${courses}">
<option name="courseOption" value="${course.name}">${course.name}</option>
</c:forEach>
</select>
${courseSelect} //for example to show it here
</body>
And this is my servlet:
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
HttpSession session = request.getSession(true);
String courseSelect = request.getParameter("courseSelect");
session.setAttribute("courseName", courseSelect);
session.setAttribute("courses", Course.allCourses());
RequestDispatcher rd = request.getRequestDispatcher("home.jsp");
rd.forward(request, response);
}
I tried to get parameters from select tag and also from option tag but it doesn't show anything. How can i solve this?