You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jerry Malcolm <2n...@gmail.com> on 2013/02/09 06:04:16 UTC

Sharing session attributes across multiple webapps

I need to set and read a session attribute across multiple webapps.  I have
googled this and have read many answers.  The general consensus is that
setting crossContext="true" and/or setting singleSignOn="true" and/or
adding emptySessionPath="true" all should make it work.  I have done all of
that, but it doesn't seem to make any difference.  I still can't, in one
app, see the session attribute that is set in another app.  As soon as I go
back to a page in the original app that set the attribute, it's still
there. I simply need a temporary string that is set during the session in
one app to still be able to be displayed when the user goes to another
app.  By the way, SingleSignOn works fine and has for years in my system.

Am I missing something obvious here?  Posts all over the web have said it
works for them. (??)

First question... 'should' I be able to see a session attribute across
sessions if I have the above config variables set correctly?

If it should work, what could I possibly be doing wrong?

If this is never intended to ever work, what are alternatives?  Somebody
suggested getContext( "aaa" ).setAttribute(....).  But if I set a context
variable, the data value going to be common to all sessions in that context
and not per user, correct?  Others have recommended setting up a database
table and/or disk files to write the data, etc.  It seems that is way
overkill to have to go that massive amount of work and performance overhead
to keep track of a temporary session variable simply because I structured
and modularized my program into a couple of different webapps.

I'm running TC 7.0.23

Thanks,

Jerry

Re: Sharing session attributes across multiple webapps

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Jerry,

On 2/9/13 12:04 AM, Jerry Malcolm wrote:
> I need to set and read a session attribute across multiple webapps.
> I have googled this and have read many answers.  The general
> consensus is that setting crossContext="true" and/or setting
> singleSignOn="true" and/or adding emptySessionPath="true" all
> should make it work.

None of those will work.

> I have done all of that, but it doesn't seem to make any
> difference.  I still can't, in one app, see the session attribute
> that is set in another app.

This is actually required by the servlet specification which mandates
that each webapp have a separate HttpSession. So, single-sign-on just
makes it so you don't have to re-authenticate with the same server to
get into a different webap, but you still have distinct sessions.
crossContext and emptySessionPath just confuse things, here.

> Am I missing something obvious here?  Posts all over the web have
> said it works for them. (??)

They must be confused.

> First question... 'should' I be able to see a session attribute
> across sessions if I have the above config variables set
> correctly?

Nope.

> If this is never intended to ever work, what are alternatives?

Any tech that will allow you to share (private?) data will work:
RDBMS, memcached, flat file, Amazon S3, etc.

> Somebody suggested getContext( "aaa" ).setAttribute(....).  But if
> I set a context variable, the data value going to be common to all 
> sessions in that context and not per user, correct?

Correct.

> Others have recommended setting up a database table and/or disk
> files to write the data, etc.  It seems that is way overkill to
> have to go that massive amount of work and performance overhead to
> keep track of a temporary session variable simply because I
> structured and modularized my program into a couple of different
> webapps.

That sounds about right. Unfortunately, you have the servlet spec
working against you, here.

> I'm running TC 7.0.23

Upgrade.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEAREIAAYFAlEWUUcACgkQ9CaO5/Lv0PA8ZwCgjlMTw+p9f3i3YVOKaSaaukof
3GUAnRVzWT0cwggMNKNY8OJ6urBJX5uv
=sRoP
-----END PGP SIGNATURE-----

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


Re: Sharing session attributes across multiple webapps

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Chris,

On 2/9/13 7:48 AM, chris derham wrote:
> <snip>
>> I simply need a temporary string that is set during the session
>> in one app to still be able to be displayed when the user goes to
>> another app.
> </snip>
> 
> <snip>
>> Am I missing something obvious here?
> </snip>
> 
> Couldn't you try a cookie?

+1

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEAREIAAYFAlEWUVQACgkQ9CaO5/Lv0PARPwCgqiCBamOvFBAozsnrsq7a/t67
TqcAoIPyVTvonQxxQtUEMwy9x1rIHV54
=MCU8
-----END PGP SIGNATURE-----

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


Re: Sharing session attributes across multiple webapps

Posted by chris derham <ch...@derham.me.uk>.
<snip>
> I simply need a temporary string that is set during the session in
> one app to still be able to be displayed when the user goes to another
> app.
</snip>

<snip>
> Am I missing something obvious here?
</snip>

Couldn't you try a cookie?

Chris

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