I am writing a jsp that lets a user pick a favorite technology and then displays the results. The problem is that my declarations keep overwriting the other variables so if you select the third option the first time then the results are correct, however if you choose option one the next time then option 3 goes to 0 and option 1 becomes 1. What could be causing this as I thought the init() method only ran once and initialized these variables.
You didn't ask, but just so you know, that JSP struck me as a very odd combination of scriptlet and JSP.
While there's (almost) never any good reason to use scriptlet code in JSP, if you *are* going to use it, it would at the very least make sense to use it appropriately.
Why put some Java code in JSP tags (the variable declarations) and other in scriptlets--doing Java is what scritplets are for? Why generate HTML in scriptlets--doing HTML is what non-scriptlet JSP is for?
Edit: Oh, right; I forgot that <jsp:declaration> creates instance variables. That makes the code even worse, although at least I understand why it's there now. My fault--seriously, I've written exactly one line of scriptlet code in the last five years--can't blame me for forgetting. (Yes, you can; I should have remembered that one.)
subject: Problem with multiple variable declaration