You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by David Durham <dd...@vailsys.com> on 2006/02/07 21:17:13 UTC

turning off sessions

Anyway to configure a Tomcat 5.5 app to not create sessions through 
META-INF/context.xml?  The closest thing I've found was the 
maxInactiveInterval attribute of the manager element.  E.g.,

<Context path="/app">
	<manager maxInactiveInterval="6"/>
</Context>


But, even that doesn't work properly.  Anyone know what I need to do?

Thanks,

-Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: turning off sessions

Posted by Tim Lucia <ti...@yahoo.com>.
    /**
     * Process HTTP request
     * @param request HTTP Request object
     * @param response HTTP Reqponse object
     */
    public void doGet(HttpServletRequest request,
                      HttpServletResponse response) 
        throws IOException, ServletException 
    {
        response.setContentType("text/plain");
        PrintWriter pw = response.getWriter();

        boolean session = request.getParameter("session") != null;
        pw.println("Session:      \"" + request.getSession(session) + "\"");
        pw.flush();
    } 


Shows:

Session:      "null"

But if I tack on ?session, it creates one as expected:

Session:      "org.apache.catalina.session.StandardSessionFacade@1395dab"


So, the JSP must be the source of the session.  I learned something new
today.  I don't know why (yet).

Tim


-----Original Message-----
From: Tim Lucia [mailto:timlucia@yahoo.com] 
Sent: Tuesday, February 07, 2006 4:49 PM
To: 'Tomcat Users List'
Subject: RE: turning off sessions

Interesting.  You are right.  A trivial jsp with only text inside produces a
session.  I am fairly certain I have seen servlets (not JSPs) behaving
without any session tracking at all.


-----Original Message-----
From: David Durham [mailto:ddurham@vailsys.com]
Sent: Tuesday, February 07, 2006 4:37 PM
To: Tomcat Users List
Subject: Re: turning off sessions

Tim Lucia wrote:
> Tomcat doesn't create sessions.  Web applications create sessions.  
> I.e., code says:
> 
> HttpSession session =
> ((HttpServletRequest)request).getSession({true|false}); // true for 
> create if not exist, false for don't create);

That's strange because there is no call to getSession() in my code.  So,
maybe it's the result of the fact that I'm using a JSP.  If that's the case,
then Tomcat is, in a sense, creating sessions.

Anyway, I think the context configuration that I had:


<Context path="/app">
     <Manager maxInactiveInterval="6"/>
</Context>


conflicts with the default session-config from conf/web.xml

     <session-config>
         <session-timeout>30</session-timeout>
     </session-config>

I added:

     <session-config>
         <session-timeout>1</session-timeout>
     </session-config>

to my app, and that's good enough for me.

Thanks.


-Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: turning off sessions

Posted by Tim Lucia <ti...@yahoo.com>.
Interesting.  You are right.  A trivial jsp with only text inside produces a
session.  I am fairly certain I have seen servlets (not JSPs) behaving
without any session tracking at all.


-----Original Message-----
From: David Durham [mailto:ddurham@vailsys.com] 
Sent: Tuesday, February 07, 2006 4:37 PM
To: Tomcat Users List
Subject: Re: turning off sessions

Tim Lucia wrote:
> Tomcat doesn't create sessions.  Web applications create sessions.  
> I.e., code says:
> 
> HttpSession session =
> ((HttpServletRequest)request).getSession({true|false}); // true for 
> create if not exist, false for don't create);

That's strange because there is no call to getSession() in my code.  So,
maybe it's the result of the fact that I'm using a JSP.  If that's the case,
then Tomcat is, in a sense, creating sessions.

Anyway, I think the context configuration that I had:


<Context path="/app">
     <Manager maxInactiveInterval="6"/>
</Context>


conflicts with the default session-config from conf/web.xml

     <session-config>
         <session-timeout>30</session-timeout>
     </session-config>

I added:

     <session-config>
         <session-timeout>1</session-timeout>
     </session-config>

to my app, and that's good enough for me.

Thanks.


-Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: turning off sessions

Posted by David Durham <dd...@vailsys.com>.
Tim Lucia wrote:
> Tomcat doesn't create sessions.  Web applications create sessions.  I.e.,
> code says:
> 
> HttpSession session =
> ((HttpServletRequest)request).getSession({true|false}); // true for create
> if not exist, false for don't create);

That's strange because there is no call to getSession() in my code.  So, 
maybe it's the result of the fact that I'm using a JSP.  If that's the 
case, then Tomcat is, in a sense, creating sessions.

Anyway, I think the context configuration that I had:


<Context path="/app">
     <Manager maxInactiveInterval="6"/>
</Context>


conflicts with the default session-config from conf/web.xml

     <session-config>
         <session-timeout>30</session-timeout>
     </session-config>

I added:

     <session-config>
         <session-timeout>1</session-timeout>
     </session-config>

to my app, and that's good enough for me.

Thanks.


-Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: turning off sessions

Posted by Tim Lucia <ti...@yahoo.com>.
Tomcat doesn't create sessions.  Web applications create sessions.  I.e.,
code says:

HttpSession session =
((HttpServletRequest)request).getSession({true|false}); // true for create
if not exist, false for don't create);

FWIW, Struts will create one for you, even if you don't need one.  This
caused me confusion once upon a time.

Tim

-----Original Message-----
From: David Durham [mailto:ddurham@vailsys.com] 
Sent: Tuesday, February 07, 2006 3:17 PM
To: users@tomcat.apache.org
Subject: turning off sessions

Anyway to configure a Tomcat 5.5 app to not create sessions through
META-INF/context.xml?  The closest thing I've found was the
maxInactiveInterval attribute of the manager element.  E.g.,

<Context path="/app">
	<manager maxInactiveInterval="6"/>
</Context>


But, even that doesn't work properly.  Anyone know what I need to do?

Thanks,

-Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org