Session attribute keeps reverting to the declared value
posted 10 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hi there guys,
being new to java I am a bit lost as to why my session attribute for this banking app wont add the deposits to the session var... it just keeps going back to the amount I set it to originally - so if I set the beginning balance to 3000 then deposit 100 it becomes 3100, but if I then try deposit another amount eg. a extra 200 it becomes 3200 not 3300 like it should be !! I must be dong something wrong can any one help me figure out what it is I have done wrong and how I can fix it ?
thanks in advanced
being new to java I am a bit lost as to why my session attribute for this banking app wont add the deposits to the session var... it just keeps going back to the amount I set it to originally - so if I set the beginning balance to 3000 then deposit 100 it becomes 3100, but if I then try deposit another amount eg. a extra 200 it becomes 3200 not 3300 like it should be !! I must be dong something wrong can any one help me figure out what it is I have done wrong and how I can fix it ?
thanks in advanced
posted 10 years ago
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
Well you correctly store the value into session:
I don't see anywhere where you retrieve that value back again though.
Something like
I don't see anywhere where you retrieve that value back again though.
Something like
posted 10 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
ok cool thanks that helped it works almost as desired now.....
Why is it that when open 2 windows of my browser of this servlet they share the same balance ? I was under the impression that it should not behave this way - they (the separate windows) should be separate and have independent session values ? So the if I deposit 100 into the first Window then deposit 400 in the second Window, the second Widow should have a balance of 400 not 500 like it is doing now. Hope this makes sense to you .
How do i get it to not react in that way, my guide lines in my course work say that if I open a second instance of my browser the 2 threads should not interfere with each other. Also I should not use synchronization only sessions to do this, I am not to sure if that is even possible, if it is how would I go about doing this ?
My code so far:
Thanks
Why is it that when open 2 windows of my browser of this servlet they share the same balance ? I was under the impression that it should not behave this way - they (the separate windows) should be separate and have independent session values ? So the if I deposit 100 into the first Window then deposit 400 in the second Window, the second Widow should have a balance of 400 not 500 like it is doing now. Hope this makes sense to you .
How do i get it to not react in that way, my guide lines in my course work say that if I open a second instance of my browser the 2 threads should not interfere with each other. Also I should not use synchronization only sessions to do this, I am not to sure if that is even possible, if it is how would I go about doing this ?
My code so far:
Thanks
Stefan Evans
Bartender
Posts: 1845
10
posted 10 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
What you are seeing is the expected behaviour. Servlet sessions are maintained by a browser session cookie. By default, most browsers share the same process/cookies among all of its windows. This is normally desirable so if you open a new window from your current one via a link, it retains the same session.
You can create multiple sessions in Internet Explorer, via the "File: New Session" option which opens up a new browser that does not share existing values.
Also as a suggestion, a lot of this servlet would be better off as a JSP page. All of those 'out.println' calls outputting HTML are the entire reason JSP was invented in the first place!
You can create multiple sessions in Internet Explorer, via the "File: New Session" option which opens up a new browser that does not share existing values.
Also as a suggestion, a lot of this servlet would be better off as a JSP page. All of those 'out.println' calls outputting HTML are the entire reason JSP was invented in the first place!
posted 10 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
ok so you telling me that the text book is wrong ? I see how what you saying makes sense (PHP works like that). Yes I know that I only did it this way because the next task I must submit states that I should update this code to use a separate .JSP file for the display of the User Interface (Is it referred to as Front End and back end in Java ? - when I was learning PHP we used terms like that)
Thanks for all the help!
Thanks for all the help!
Stefan Evans
Bartender
Posts: 1845
10
posted 10 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
It is possible the textbook is outdated. "if I open a second instance of my browser the 2 threads should not interfere with each other. "
That sounds right to me. The only question is how do you open up a second (independent) instance? It is no longer as easy as just clicking on a shortcut (though it used to be)
How old is the textbook?
If you know the PHP concepts, many of them are the same. and yes referring to the browser as the front end and the server as the back end is the standard approach.
Understanding which bits of code run where is a fundamental concept.
That sounds right to me. The only question is how do you open up a second (independent) instance? It is no longer as easy as just clicking on a shortcut (though it used to be)
How old is the textbook?
If you know the PHP concepts, many of them are the same. and yes referring to the browser as the front end and the server as the back end is the standard approach.
Understanding which bits of code run where is a fundamental concept.
posted 10 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
It is very dependent upon browser and platform.
posted 10 years ago
Clarification: which means that server-side templating engines like JSP and PHP are part of the backend. Lots of people refer to these as front-end technologies because they equate "front-end" with the GUI layer.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Stefan Evans wrote:and yes referring to the browser as the front end and the server as the back end is the standard approach.
Clarification: which means that server-side templating engines like JSP and PHP are part of the backend. Lots of people refer to these as front-end technologies because they equate "front-end" with the GUI layer.
posted 10 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Thanks Guys i get it ... so yes the copy i have is 2006 print ....I found a digital copy of the book...(Text Book Question 6 on this page)
its possible I misunderstood misinterpreted the question?
Thanks again you guys rock!!
its possible I misunderstood misinterpreted the question?
Thanks again you guys rock!!
| There were millions of the little blood suckers. But thanks to this tiny ad, I wasn't bitten once. The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |












