Announcement Announcement Module
Collapse
No announcement yet.
Does web.xml tracking-mode breaks Spring session scoped bean? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Does web.xml tracking-mode breaks Spring session scoped bean?

    Hi,

    I am running a Spring MVC application on Tomcat 7 and I would like to prevent Tomcat from adding the 'jsessionid' parameter to the URL. I have read that Tomcat 7 supports this by adding the 'tracking-mode' parameter to the web-app web.xml, which disables URL-based sessions.

    So in my web.xml, I have added this.

    Code:
    	<session-config>
    		<session-timeout>60</session-timeout>
    		<!-- Disables URL-based sessions (no more 'jsessionid' in the URL using Tomcat) -->
    		<tracking-mode>COOKIE</tracking-mode>
    	</session-config>

    In my controller I have injected a session-scoped bean. The session scoped bean is defined in my spring-mvc.xml like this:

    Code:
    	<bean id="foo" class="com.bar.Foo" scope="session">
    		<aop:scoped-proxy />
    	</bean>
    In the controller classes, the session bean is injected using the @Autowired annotation.

    What works is, that the 'jsessionid' parameter is no more added to the URL!
    But, when I add stuff to the session bean in a controller class, values get lost on the next request.
    This is not the case, when removing the "tracking-mode" statement from the web.xml.

    Debugging shows that the session bean is being created on each request. Why is that?
    Any ideas what I am missing here?

    Thanks.
    Paul

  • #2
    Solved.

    Hi,

    my mistake. In my web.xml, I found the following section in the <session-config> caused the described behaviour:

    Code:
    		<cookie-config>
    			<secure>true</secure>
    		</cookie-config>
    After I removed the 'cookie-config' section, the Session scopes bean works even using 'tracking-mode'.

    I just can not explain why...
    Paul

    Comment

    Working...
    X