reset password
Author Message
afetiso
Posts: 84
Posted 06:14 Mar 15, 2014 |

I need to increase int i ++ (on servlet) every time I push next button. How I can make it? 

and if I have a List of string and I wont to take string with different id from that list, connected with this int i, what i need to do in .jsp and in servlet

i have:

List<String> quart = new ArrayList();

for (int z=0; z < enter.size(); z++){
            for (String qr:quarterList){
                quart.add(qr + " " + (year+z));
            }
        }

and i need in .jsp something like  ${ quart[i] }  =  string i from quart.

cysun
Posts: 2935
Posted 09:55 Mar 15, 2014 |

If you need quart[i] in JSP, you can do something like this in the controller:

request.setAttribute("quarter", quart[i]);

and then in JSP you can do ${quarter}.

I'm not sure what you are trying to do in your controller, but it looks wrong. To advance quarter, you just need to keep the current quarter in session, and then calculate the next quarter based on that:

quarter = request.getSession().get("quarter");
quarter = ...; // calculate next quarter based on current quarter
request.getSession().setAttribute("quarter", quarter); // now "next" quarter becomes the "current" quarter
Last edited by cysun at 09:56 Mar 15, 2014.
afetiso
Posts: 84
Posted 12:33 Mar 15, 2014 |

thank you got it