• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

session question

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I am using a cookie to manage session state, If I launch another IE from start menu what determines if that IE browser window will be using the session with cookie or it will be a new session?
 
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it will be a new session. you could of kept all this in one thread you know.
if you want to keep them logged in in multiple windows you have to write and read your own cookies
 
Author
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

If I am using a cookie to manage session state, If I launch another IE from start menu what determines if that IE browser window will be using the session with cookie or it will be a new session?


Good question. Let's assume that you are using the default way of session tracking (which is where the server sends the JSESSIONID without a max age, so the cookie is kept in the browser's memory, not stored on disk).
  • If the user opens a new IE window from the Start Menu or desktop icon, that new IE window will not share the in-memory cookies with the old window, so thus will be in a new session from the Java perspective.
  • If the user opens a new IE window from the old window's File menu or by hitting Control-N, that new IE window will share the in-memory cookies and will be part of the same Java session.


  • Also, don't forget that the spec advertises the name of the cookie that will be used (JSESSIONID). So, you can resend that cookie with a max age, and then use the normal session tracking API after that.
    Cheers-
    - Marty
     
    Ranch Hand
    Posts: 937
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by Marty Hall:

  • If the user opens a new IE window from the Start Menu or desktop icon, that new IE window will not share the in-memory cookies with the old window, so thus will be in a new session from the Java perspective.


  • Suppose a user is filing a registration form which contains two or more pages. And if the user opens one more window and submitting two forms , how to track the user?
    For example filing a tax returns which system doesnt want the user to submit twice.
  • If the user opens a new IE window from the old window's File menu or by hitting Control-N, that new IE window will share the in-memory cookies and will be part of the same Java session.
  • [/list]
    So if the user shares the same session, how to track the user?

     
    Jean Miles
    Ranch Hand
    Posts: 53
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    thanks marty, this info has help me alot. I am also interested on questions mazha thulli had asked.
    [ November 13, 2003: Message edited by: Jean Miles ]
     
    Ranch Hand
    Posts: 8945
    Firefox Browser Spring Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    So if the user shares the same session, how to track the user?


    Both the windows will be using the same session IDs.
     
    Ranch Hand
    Posts: 3178
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by mazha thulli:
    Suppose a user is filing a registration form which contains two or more pages. And if the user opens one more window and submitting two forms , how to track the user?
    For example filing a tax returns which system doesnt want the user to submit twice.


    Surely we have to define a flag that shows whether the user has already submitted or not... And remember that the data source that saves the flag should be protected from concurrent accessing...
     
    Pradeep bhatt
    Ranch Hand
    Posts: 8945
    Firefox Browser Spring Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I think she was talking about 2 concurrent submits.
     
    Ko Ko Naing
    Ranch Hand
    Posts: 3178
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by Pradeep Bhat:
    I think she was talking about 2 concurrent submits.


    If so, we have to use the servlets, which implement SingleThreadModel. But for servlets not implementing the SingleThreadModel interface, if the
    service method (or methods such as doGet or doPost which are dispatched to the service method of the HttpServlet abstract class) has been defined with the synchronized keyword....
    It is strongly recommended that Developers not synchronize the service method (or methods dispatched to it) in these circumstances because of detrimental effects on performance....
     
    Pradeep bhatt
    Ranch Hand
    Posts: 8945
    Firefox Browser Spring Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    We can store the submitted application's user ID in some data structure in the aplication context. If some one submits it successfully, make an entry in the data structure. We can also detect multiple entires at the database level
     
    sunitha reghu
    Ranch Hand
    Posts: 937
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by Ko Ko Naing:

    If so, we have to use the servlets, which implement SingleThreadModel. But for servlets not implementing the SingleThreadModel interface, if the
    service method (or methods such as doGet or doPost which are dispatched to the service method of the HttpServlet abstract class) has been defined with the synchronized keyword....
    It is strongly recommended that Developers not synchronize the service method (or methods dispatched to it) in these circumstances because of detrimental effects on performance....



    So are you suggesting to use SingleThreadModel interface?
    Pradeep im not talking abt concurrent submits. That I can always be solved by setting a flag. Im pasting Jeans question in another thread which basically same in this question.

    Problem is that I don't want same user in multiple IE windows updating the same data at the same time. So if I can restrict an user to only one session in the application, not multiple then I can solve the problem. However, I couldn't think of another way to handle this other than i keeping track of user session in database. If user has entry in database then send back a message that user has session in another browser window. To make sure database entry is removed, when the session terminates put a listener on session so when it invalidates I removed the entry in the database. However there are problems with this, if the user can close the IE window, the session is active until it timeout in the meantime the user launch another IE window with new session, since the entry is still in the database the code will denied them.
     
    Consider Paul's rocket mass heater.
    reply
      Bookmark Topic Watch Topic
    • New Topic