You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Andy <an...@fritter.net> on 2005/11/14 22:18:01 UTC

request.getSession(false) incorrectly creates a session

Hi,

When I deploy my web app and call request.getSession(false), according to
the
javadoc, if a session does not exist null is returned. However I'm getting
an
object returned when I have not created a session myself.

The object is an instance of this class -

org.apache.catalina.session.StandardSessionFacade

As a result my unit tests, using mock objects, all work fine, but when I
deploy my  application it breaks because a session is created incorrectly,
it seems to me.

I'm using Tomcat 5.5. Anybody care to enlighten me?

Thanks,

Andy.



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


Re: request.getSession(false) incorrectly creates a session

Posted by "Darryl L. Miles" <da...@netbauds.net>.
<jsp:useBean id="foobar" scope="session" class="com.yourdomain.Foobar" />

"The session is not explicitly created by anything in the JSP page", 
does this include scope="session" users in your JSP files  ???


Len Popp wrote:

>I have observed that request.getSession(false) returns null when it's
>called from the top of my servlet in the first request from a client,
>but when the servlet forwards the request to a JSP page (via
>RequestDispatcher.forward) the session gets created. The session is
>not explicitly created by anything in the JSP page but something is
>doing it. That's as far as I've got - I haven't dug into the Tomcat
>code.
>  
>


-- 
Darryl L. Miles



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


Re: request.getSession(false) incorrectly creates a session

Posted by Len Popp <le...@gmail.com>.
I have observed that request.getSession(false) returns null when it's
called from the top of my servlet in the first request from a client,
but when the servlet forwards the request to a JSP page (via
RequestDispatcher.forward) the session gets created. The session is
not explicitly created by anything in the JSP page but something is
doing it. That's as far as I've got - I haven't dug into the Tomcat
code.
--
Len

On 11/14/05, Andy <an...@fritter.net> wrote:
> Hi,
>
> When I deploy my web app and call request.getSession(false), according to
> the
> javadoc, if a session does not exist null is returned. However I'm getting
> an
> object returned when I have not created a session myself.
>
> The object is an instance of this class -
>
> org.apache.catalina.session.StandardSessionFacade
>
> As a result my unit tests, using mock objects, all work fine, but when I
> deploy my  application it breaks because a session is created incorrectly,
> it seems to me.
>
> I'm using Tomcat 5.5. Anybody care to enlighten me?
>
> Thanks,
>
> Andy.

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


RE: request.getSession(false) incorrectly creates a session

Posted by Andy <an...@fritter.net>.

Len - Ahh, nice to know it's not my imagination. Well never mind, I just
wrote a
kludge to work around it for now.

Tim - Thanks for the reply but I test stuff using Spring's mock objects so
no actual JSP's are involved, anyway seems it is broke in some cases.

Andy.


-----Original Message-----
From: Tim Funk [mailto:funkman@joedog.org]
Sent: 15 November 2005 11:56
To: Tomcat Users List
Subject: Re: request.getSession(false) incorrectly creates a session


If you are using jsp - you need <%@page session='false'%> in your page
otherwise - a session is created for your whether you use it or not.

-Tim

Andy wrote:
> Hi,
>
> When I deploy my web app and call request.getSession(false), according to
> the
> javadoc, if a session does not exist null is returned. However I'm getting
> an
> object returned when I have not created a session myself.
>
> The object is an instance of this class -
>
> org.apache.catalina.session.StandardSessionFacade
>
> As a result my unit tests, using mock objects, all work fine, but when I
> deploy my  application it breaks because a session is created incorrectly,
> it seems to me.
>
> I'm using Tomcat 5.5. Anybody care to enlighten me?

---------------------------------------------------------------------
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: request.getSession(false) incorrectly creates a session

Posted by Tim Funk <fu...@joedog.org>.
If you are using jsp - you need <%@page session='false'%> in your page 
otherwise - a session is created for your whether you use it or not.

-Tim

Andy wrote:
> Hi,
> 
> When I deploy my web app and call request.getSession(false), according to
> the
> javadoc, if a session does not exist null is returned. However I'm getting
> an
> object returned when I have not created a session myself.
> 
> The object is an instance of this class -
> 
> org.apache.catalina.session.StandardSessionFacade
> 
> As a result my unit tests, using mock objects, all work fine, but when I
> deploy my  application it breaks because a session is created incorrectly,
> it seems to me.
> 
> I'm using Tomcat 5.5. Anybody care to enlighten me?

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