Is it possible to put swicthcase inside While loop? I’m trying but I cant pass the value to another page, it only displays null
<form action="NewFile1.jsp" method="get">
Birthday: <br>
<%! int i = 1, j;
String mon = "";%>
<%
out.println("<select name='month'>");
while(i <= 12) {
out.print("<option>" + i + "</option>");
i++;
}
out.print("</select>");
%>
<input type="submit" value="submit">
</form>
</body>
Page to output the selected value in combo box
<body>
<%
//String mo = request.getParameter("month");
String mo = "";
switch(request.getParameter("month")) {
case "1": mo = "January"; break;
}
%>
<%=out.print("Birthday: " + mo)%>
For example, in the combo box are numbers representing the month respectively. If the user selected 2, it should dislpay “February” on the next page.
Try with int, instead of String: