Results 1 to 4 of 4

Thread: Sessions between controllers

  1. #1
    Join Date
    Oct 2007
    Posts
    14

    Default Sessions between controllers

    Hi,

    I'm using a simple spring MVC setup with the webapp being loaded from an embedded Jetty server. I have 1 controller that handles various forms of request by extending MultiActionController. This is the process. The controllers
    Load method is called, that loads some details into an object, sticks the object in the session, and then returns to the page to display the results. Some more details are entered and the controllers start method is invoked, which then makes use of the object entered into the session in the Load method.

    What I'm finding is that when I open the app in two browsers, I am getting the objects in the session mixed up. Why are the sessions shared between two different browsers? How can I store an object in the session without it getting shared between two browser sessions?

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    My assumption you are opening a "new browser" using CTRL+N instead of really opening a new browser by clicking on the icon/menu option. (Although if you use Firefox this is also not going to work because it is detecting the current browser instance).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Oct 2007
    Posts
    14

    Default

    Hi,

    You're correct! I didn't realise that double clicking firefox.exe created new browsers in the same process! Thanks very much

    Also, I think Jetty allows 255 connections at the same time. Do i need to set the controller to singleton="false" to ensure each connection is served by its own instance of the controller?

    Rich

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    If your controller is stateless it doesn't matter if it is a singleton.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •