The current values display in the form. After changing any of the fields and pressing submit, I expect to see the new values from the servlet, but it just prints out the old values. I have no idea why. I obviously have setters in the User class. I do the same thing in user registration, which works perfectly. The only difference is that in the registration form, I instantiate the object with a <jsp:useBean>, but it should be working when accessing an existing object from the session too, right??
Maybe I'm wrong, or missing something obvious, it should be easy to get this working, but I've been stuck here for too long....
setAttribute method of HttpSession is never used in the code, means User object in the session scope not changed/updated.
Andre Solberg wrote:The only difference is that in the registration form, I instantiate the object with a <jsp:useBean>
User object in the session scope must have changed/updated, may be by using jsp:setproperty tag(i guess the scope attribute in jsp useBean tag must have the value as session).
Difference between these two is, first one takes a copy of User object from session and updates copied User object 's attribute and updates it into session; Second one directly uses the User object from session.
I am little late
posted 9 years ago
Oh ok, I see I've misunderstood........................
I handle the registration in a separate jsp instead of servlet. I forgot about the <jsp:setProperty name="user" property="*"/> within the <jsp:useBean>.
I guess I just thought there was some magic that automatically filled the bean with the values from the fields as long as the setters where right ...
But when doing this in a servlet, does that mean I have to manually fill in each and every property from the request and put in in the bean? I can't put the <jsp:setProperty> in before I submit or in the servlet? If so, then damn...