Reqest.getParameter() Returns Null For Select Box In JSP
I have the following code in a jsp file (on Adobe CQ) but, it returns null. Not sure why. I am expecting the out.println line to return 40 since it is the default selected value. &
Solution 1:
your code will always return null
. try to see page source
after running your application. value of Items
is always null
.
try following code: (in this code I am sending a request on every time the value of combobox is changed)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body onload="form1.submit();">
<form action="#" name="form1">
<select id="itemsperpage" name="itemsperpage" onchange="submit();">
<option value="20">20</option>
<option value="40" selected>40</option>
<option value="100">100</option>
<option value="200">200</option>
</select>
</form>
<%
String itemsPerPage = request.getParameter("itemsperpage");
out.println("Items: " + itemsPerPage );
%>
</body>
</html>
[Note: i will suggest you to not use scriplets
in your jsp file, instead you can go for AJAX , JSTL etc. ]
Post a Comment for "Reqest.getParameter() Returns Null For Select Box In JSP"