May be i am very new to ejb and especially serverside.com as i recently started working on a live ejb project .... now i am facing a problem which do happen in general internet-web based applications ... i.e session management.
In our current application we have multiple clients coming and logging in and do their business transactions.. so for every client logging in we maintain the session id .. that is what being done througout internet sites we also do the same ..
the difference is ..
our application uses a servlet which inturns .. takes all the dForm variables of the page into the session ..
and our data ,.. in the database is maintained fully on one primary key .. let;s say ID..
so in every sesssion having different session id we also have a id i.e our unique key in every sesion
but what is happening sometimes is ..
suppose i have 2 windows X and Y . X window has id = 1 and y has id = 2 .
session id of both are different .. and also the id is different..which is our primary key ..
but some times what happens is the id of window y by some how it happens to window x and then what happens is unimaginable ..
the data of one goes into the another into the database...
and then no one knows what is happening ...
i wanted to know few questions for why it is happening so ..
1. is the design architecture wrong for maintaining session
2. is the problem with multiple instances opening of same application
3. if every session has a session id how can it happen that one session variable invariable goes into anothers session ..
4. If out of this none is the possibility of hapening this case what is the probable think which u might think is causing this problem
5. what is the suggestive solution for the same
if you require more information please write back i would be happy to get the solution of this problem..
Thanks in advance ..
Threading could be the issue here.
I faced a similar problem. The issue was we were not synchronising
on an object which was renedering data for all the requests.
If I understand you correctly :
Are you using HttpSession(servlet api) for session management?
If so, 2 browser windows might, depending on browser and how they were lanuched, share the same cookies(I'm assuming cookies here). Which in turn means same HttpSession. so if you first create one session a with browser window "x", then open a new window "y" and start a new session b. Session b will now be the only session for both browser window x and y.
I had a similar problem with multiple windows in the same app. To avoid overwritting session and variables each window would pass a unique namespace. Using a Filter the namespace would prefix the names of parameters. You can in tern modify your code to use the namespace to load values into session and access the session attributes with namespace prefix. You can also create a decorator wrapper for the Request class which return a Wrapper for Session to add prefix to attibutes getters and setters. The wrapping can be perfomed in the Filter and minimize change to just your jsp pages and a Filter, HttpRequest and HttpSession Wrapper (pretty easy extending the WrappedHttpRequest class)
This sounds like a workable solution - can you provide me with more details on how you setup a unique namespace for a browser window?
Everybody who replied to the message are on the right tract, but for the sake of clarity until i reach a solution to my problem i more presisely define what architecture i am using which might be a cause of this problem.
our architecture is using ejb 1.1 and it was designed for jrun which we finally upgraded to weblogic, and our database server is oracle.
now in our architecture Most of the emphasis is making on forms , we have two types of forms in any html page one is inputform in which user makes the entry and another is sessionform which is hidden. now what every values are set in the sessionform are set into the session using a dispatcher servelt which takes all the sessionform parameters and set it into the session.
for for any html page whenever we need to go to any other page we use the dispatcher servlet to go to another page so in that page if we want any previous page field and it that is set in sessionform we can easily get that using the request.getString from the session ..
so either the problem is there in the dispatcher where any discrepancy in the session management would lead to data transfer from one session to another and this is not happening very regularly .. but it is happenning in the system ..
and while i am an developer working on this i am unable to repoduce the same ..
but there is a problem that is for sure .. and i have to verify where it is and u would help me to reach my goal
any questions on the same are always welcomed .. and i appreciate if i get the solution through the medium of theserverside.com