I've two JSP files, where each one is accessed by different PCs.
In the first one, I'm creating an object of type Integer
:
Integer var = 0;
application.setAttribute("name_var", var);
At the second one, I'm getting the attribute created before:
var = (Integer) application.getAttribute("name_var");
At this point everything is fine. I've my value at the second JSP, in a different PC.
Since Java is pass-by-value, where that values are references (Is Java "pass-by-reference" or "pass-by-value"?), I guess I've the same instance in both the JSP files (being visited by different PCs).
So now, When I'm modifying my var value, and It doesn't appear modified in the other side, I don't understand why.
var++;
Output (in the JSP where the attribute was set): 0 (still)
Can anyone explain me what is happening? Have I to update the object with a setAttribute
each time I modify its value?
Thank you in advance