Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java session problem  RSS feed

 
Padmaja Singanamala
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai, My problem is : In a jsp form i have several case-form links. If i open one case-form and navigate through its form and again if i open a second case form without closing the first opened case form, i can see the first case fields & its values on the secong case form...This is because we are getting the values of the fields in session. As i am not closing the page, it is carrying to the second form too..How to avoid this problem? Please suggest me any solution for this...i can open only 1 case-form at a time.

Thanks for patiently reading my problem...and thanks in advance for the help...
 
Himanshu Kansal
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you feeding values to a case form?
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sessions are typically stored in cookies, and how cookies are shared between tabs / windows is browser and configuration dependent, but typically they are shared, and you should assume that all windows / tabs from a given client will share the same cookies.

The solution is to NOT use cookies to store session ids. This requires work - including re-writing every URL so that it encodes the session id when needed (you should do this anyway) and re-configuring the application container to not use cookies. To learn more you should be able to google for Java servlet session management, or something similar, to get details.
 
Padmaja Singanamala
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Himanshu, i am getting values for the case(jsp) form through session.
 
Rob Spoor
Sheriff
Posts: 21092
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to JSP.
 
Padmaja Singanamala
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Steve,

Thanks for the detailed explanation. Just to mention you, my problem is not at all related to cookies as i am not using cookies anywhere in my application. It purely session problem. Session object is storing the preious jsp form values and displaying in the another jsp form This happens when the second jsp form is opened without closing the first jsp form. I want help regarding how to avoid showing wrong values.



 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Padmaja Singanamala wrote:Hi Steve,

Thanks for the detailed explanation. Just to mention you, my problem is not at all related to cookies as i am not using cookies anywhere in my application. It purely session problem. Session object is storing the preious jsp form values and displaying in the another jsp form This happens when the second jsp form is opened without closing the first jsp form. I want help regarding how to avoid showing wrong values.


How does your container track a user with his session?

This is typically done using cookies - and typically using a cookie names jsessionid with the application's domain. So you may not be using cookies, but the JEE container you are using that controls sessions most likely is.
 
Himanshu Kansal
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it necessary to feed the form from session? Can the form be empty or contain static default values when opened?
If the answers to the above questions are YES and NO then use request instead of session. I assume that the request is not shared b/w the 2 JSPs.

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!