jsp - Cannot iterate through HttpSession after going to the controller for 2nd time -



jsp - Cannot iterate through HttpSession after going to the controller for 2nd time -

in controller have :

switch(testing){ case "display" : arraylist<> list = new arraylist<>(); list.add(filldata) // string values httpsession test = request.getsession(); test.setattribute("testdata",list); test.setmaxinactiveinterval(50000); break; case "read" : arraylist<> list2 = new arraylist<>(); // logic request.setattribute("testdata",list2); break; } requestdispatcher view = request.getrequestdispatcher("/" + page); // jsp page view.forward(request, response);

and in jsp have :

<c:choose> <!-- iteration works , sessionscope.testdata not null. --> <c:when test="${sessionscope.testdata !=null && requestscope.testdata == null> <c:foreach items="${sessionscope.testdata}" var="elems" varstatus="ctr"> <input type="text" value="${lookups}"/> </c:foreach> </c:when> <c:otherwise> <c:foreach items="${requestscope.testdata}" var"inputs" varstatus="count"> <!-- iteration doesnt work , sessionscope.testdata not null when check it. i've checked if sessionscope.testdata null isnt. --> <c:foreach items="${sessionscope.testdata}" var="elems" varstatus="ctr"> <input type="text" value="${lookups}"/> </c:foreach> </c:foreach> </c:otherwise> </c:choose>

test case:

when start page goes controller action = "display". , displays values of session attribute in jsp. on jsp there button calls controller 1 time again passing action = "read". when goes jsp. go <c:otherwise> section , (for illustration requestscope.testdata has 2 values) iterate on requestscope.testdata part. upon next <c:foreach> won't iterate. mentioned above. checked session attribute null, isn't. perchance wrong here won't iterate through session part? help much appreciated. thanks.

jsp session servlets controller jstl

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -