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 M. Rosner" <da...@recommend-it.com> on 2001/05/15 22:26:27 UTC

Add logic to session tracking?

Hello All,

As a developer using Tomcat, is there anyway to override or add logic to 
parts of Tomcat's session tracking/setting mechanisms? Or do I need to get 
my hands on the source code, make changes, and then recompile?

Basically I want to add my own session tracking ALONG with Tomcat's so that 
my network load balancer can use the values to create sticky sessions.

Thanks




Re: Add logic to session tracking?

Posted by "David M. Rosner" <da...@recommend-it.com>.
>..
>As long as you know this is not standard :-), you will have to make some
>changes to the session interceptor or create a new one.
>
>In 3.3, the code is in modules.session.SessionId, you should probably
>create a new module, add an option and code that supports what you
>need, and maybe publish the changes for others :-)
>
>I don't think this can be commited in jakarta-tomcat, as it is not
>standard and it's not a required feature, but it would be nice to have it
>somewhere.
>
>
>Costin


Hi - thanks for the response. After some research I found that I could 
rewrite my own request.SessionInterceptor and change the server config to 
use this instead of the one in Tomcat. All I needed to do was add an 
additional cookie to be set in the beforeBody() method. This works great 
and allows me to set an additional cookie with a server name in it.

The problem i'm now having is getting that server name/value to be written 
in the URL if cookies are shut off. Any ideas what I need to do to get that 
to work. Just changing the contextMap() method doesn't seem to make it 
work. I'm using 3.2.2

Thanks

-dave


Re: Add logic to session tracking?

Posted by Bo Xu <bo...@cybershop.ca>.
"David M. Rosner" wrote:

> Hello All,
>
> As a developer using Tomcat, is there anyway to override or add logic to
> parts of Tomcat's session tracking/setting mechanisms? Or do I need to get
> my hands on the source code, make changes, and then recompile?
>
> Basically I want to add my own session tracking ALONG with Tomcat's so that
> my network load balancer can use the values to create sticky sessions.
>
> Thanks

Hi :-)  I am not sure, I suggest you read the following:

On Mon, 14 May 2001, Mihai Popoaei wrote:
> Hello,
>
> How can I have the same session for many web sites?
>
> By default, for the first request tomcat creates a implicit session and
> sends a cookie with domain=servername. What I wanna do is setting this
> cookie for domain=partian domain name (like .kiki.ro) (that means this
> cookie will come back for all the hosts ending with .kiki.ro and I'll have
> the same session for all the sites :)). I think I have to say that I use
> the same application context for all this sites...
>
> Another problem is using the same session between applications... I know
> it is not conform the sun specifications (... HttpSession objects must be
> scoped at the application / servlet context level. The underlying
> mechanism, such as the cookie used to establish the session, can be shared
> between contexts, but the object exposed, and more importantly the
> attributes in that object, must not be shared between contexts. ...),
> but there must be a way to do that...
>

...
You are perfectly free to "roll your own" session implementation that
meets your needs (cross-host and cross-webapp).  However, the standard
APis don't support these uses, so this will definitely be an application
specific (and probably Tomcat-specific) approach.

When you try this, you'll discover that having a cookie recognized
correctly is the least of your problems.  You'll also need to ensure that
all of the classes are loaded from a shared class loader -- classes that
are loaded from one web-app's /WEB-INF/classes or /WEB-INF/lib directory
are not visible to any other web-app.
> thx,
>  --
> :], Mihai P.
>
Craig


...
As long as you know this is not standard :-), you will have to make some
changes to the session interceptor or create a new one.

In 3.3, the code is in modules.session.SessionId, you should probably
create a new module, add an option and code that supports what you
need, and maybe publish the changes for others :-)

I don't think this can be commited in jakarta-tomcat, as it is not
standard and it's not a required feature, but it would be nice to have it
somewhere.


Costin





Bo
May.16, 2001




RE: Add logic to session tracking?

Posted by Filip Hanik <ma...@filip.net>.
you will have to modify or replace the
org.apache.tomcat.request.StandardSessionInterceptor.
The session tracking in Tomcat is implemented according to the
specification, hence there is no way you can modify it without actually
changing the source code or replacing the interceptor.

Filip

~
Namaste - I bow to the divine in you
~
Filip Hanik
Software Architect
filip@filip.net
www.filip.net

> -----Original Message-----
> From: David M. Rosner [mailto:dave@recommend-it.com]
> Sent: Tuesday, May 15, 2001 1:26 PM
> To: tomcat-user@jakarta.apache.org; tomcat-user@jakarta.apache.org
> Subject: Add logic to session tracking?
>
>
> Hello All,
>
> As a developer using Tomcat, is there anyway to override or add logic to
> parts of Tomcat's session tracking/setting mechanisms? Or do I
> need to get
> my hands on the source code, make changes, and then recompile?
>
> Basically I want to add my own session tracking ALONG with
> Tomcat's so that
> my network load balancer can use the values to create sticky sessions.
>
> Thanks
>
>
>
>