I want to have a Variable in a Session. In a Scenario i am fetching a variable from the session will replace back after incrementing it. But in the .SetAttribute we are allowed to have only the Objects. So i created an abject for int fromt the Wrapper Class ie Integer(0). Now i am able to set it in a Session.
Is it possible to convert this Integer(0) 's Object to its primitive type ie int. or is it possible to directly increment the object of the Wrapper Class with ++ Operater.
The code is as follows ------------------------------------------------------------------------- HttpSession hSess= request.getSession(false); hSess.setAttribute("counter",new Integer(0)); // new Integer Object is set in session
------------------------------------------------------------------------ Code to fetch and increment in a .jsp page (code in enclosed in a scriplets) =---------------------------------------------------------------------- Integer YO= new Integer(0);
// fetching the Objct from the Session YO=session.getAttribute("counter"); YO++// this fires error..
This question really has little to do with sessions, and more to do with primitive wrapper calsess, so I've moved this to the Java in General (beginner) forum.