You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Joshua Wang <zh...@gmail.com> on 2015/01/16 03:00:08 UTC

how should i configure to use one session

Hi,
I'm using tomcat 6, and i have an application deployed into webapps and
re-named ROOT, so users can visit using http://ip:8080/.
But i need to configure that when users input http://ip:8080/portal.do and
http://ip:8080/csmis also can visit the same site. So i added <Context>
into server.xml like below:
<Context  path="/portal.do" docBase="ROOT"></Context>
<Context  path="/csmis" docBase="ROOT"></Context>

And it does work, but there's also a problem. When user input
http://ip:8080/portal.do visit the site and login, the Root path can not
get the session. In other words, he was asked to re-login when he open some
page from portal.do such as http://ip:8080/a.jsp.
Is there anything i can solve this?

Thank you very much!

yours'
Joshua

Re: how should i configure to use one session

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

Joshua,

On 1/16/15 1:36 AM, Joshua Wang wrote:
> But i see sessionCookiePath, sessionCookieName and
> sessionCookieDomain configures, what is those used for?

Those are used for customizing the details that Tomcat will use when
creating a JSESSIONID cookie to send to the client. If you set the
sessionCookiePath to "/" instead of "/context" then your JSESSIONID
cookie will be sent to any URL on that same host. If you have multiple
web applications there that all expect to use a "JSESSIONID" cookie,
you'll confuse all of them simultaneously.

> And apache says they just don't recommend to add context into
> server.xml, besides, xml files can be putted into
> conf\Catalina\localhost

Correct: you should use XML files in conf/Catalina/localhost because
they can be re-loaded without restarting the whole container.

- -chris

> On Fri, Jan 16, 2015 at 11:24 AM, Christopher Schultz < 
> chris@christopherschultz.net> wrote:
> 
> Joshua,
> 
> On 1/15/15 9:00 PM, Joshua Wang wrote:
>>>> I'm using tomcat 6, and i have an application deployed into
>>>> webapps and re-named ROOT, so users can visit using
>>>> http://ip:8080/. But i need to configure that when users
>>>> input http://ip:8080/portal.do and http://ip:8080/csmis also
>>>> can visit the same site. So i added <Context> into server.xml
>>>> like below: <Context  path="/portal.do" 
>>>> docBase="ROOT"></Context> <Context  path="/csmis" 
>>>> docBase="ROOT"></Context>
> 
> You should not configure web applications in server.xml. Instead, 
> deploy them properly:
> 
> http://tomcat.apache.org/tomcat-6.0-doc/config/context.html#Defining_a_context
>
> 
>>>> And it does work, but there's also a problem. When user
>>>> input http://ip:8080/portal.do visit the site and login, the
>>>> Root path can not get the session. In other words, he was
>>>> asked to re-login when he open some page from portal.do such
>>>> as http://ip:8080/a.jsp. Is there anything i can solve this?
> 
> No. Even with single-sign-on, all web applications have separate 
> HttpSessions. If you want to share state between them, you'll need
> to implement something yourself.
> 
> Suggestions: RDBMS, memcached, etc.
> 
> -chris
>> 
>> ---------------------------------------------------------------------
>>
>> 
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>> 
>> 
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org

iQIcBAEBCAAGBQJUuTUMAAoJEBzwKT+lPKRYR8oQALqGg+LyEi7mdaO+TaGfXtME
DJXXj7x7fGFjCKkm+Ye70ioYOsBYTTTMulZ67YdSXGrb5lDHXbxWAQJwTAaYLzKY
3uKFuH/oNxinVwWZ8KPsth78Xy+abZJ2SAFrR9eNvyi+Qyzsy57KZ/NxsHa2OTfi
iLtXmy2ULbWtdaKPQMtfwQ7rdK7iztoHtitDX6K6sNu01m/r5d0rIH4gsDg5uN6n
DyWzlmBHHFTQdK/qb1Knpqn2sTDlJwQ+rN/P2dHa/MpmG18GoXCkBLZAwWL1uH16
POkzPJPHr8ZJeBpbJvBEt2lZJb+JAggXDSAu4yTTKM2NdDN2ziO3OoRmrXoPL+wa
5YIja1VFC3Qtw88fGagprGh1Negc8mrMOD2ziGNAEvpM/yrencmaISyLPQzhmFsN
+nYQ9d9nhElJ9YWoGDlIVVfJTZCzRQOPCltTfTQsFSam/EkY4wNWNeXpEZbWHWdK
nADY0n0Hevzg/Nwp7vqPVnpalSQoE4ToKrbU7XRGPiVS3XAJdMH1DmUg6BuaXs5x
CBBQAT10fiuCWmpu5Hc4UQ9f1HcLSOer3XlLVO4FvqMYQBgVm5ORlVaeSSiyDps+
Fg406FqjvEzdFm5rYHujivwMXLB42ChuKDJGDWGDzFZP+8oBVtsicNw7ejFP3bxT
hwCWaA/idLSds6brxDKJ
=2mzB
-----END PGP SIGNATURE-----

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


Re: how should i configure to use one session

Posted by Joshua Wang <zh...@gmail.com>.
Hi,
But i see sessionCookiePath, sessionCookieName and sessionCookieDomain
configures, what is those used for?
And apache says they just don't recommend to add context into server.xml,
besides, xml files can be putted into conf\Catalina\localhost

Joshua

On Fri, Jan 16, 2015 at 11:24 AM, Christopher Schultz <
chris@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> Joshua,
>
> On 1/15/15 9:00 PM, Joshua Wang wrote:
> > I'm using tomcat 6, and i have an application deployed into webapps
> > and re-named ROOT, so users can visit using http://ip:8080/. But i
> > need to configure that when users input http://ip:8080/portal.do
> > and http://ip:8080/csmis also can visit the same site. So i added
> > <Context> into server.xml like below: <Context  path="/portal.do"
> > docBase="ROOT"></Context> <Context  path="/csmis"
> > docBase="ROOT"></Context>
>
> You should not configure web applications in server.xml. Instead,
> deploy them properly:
>
> http://tomcat.apache.org/tomcat-6.0-doc/config/context.html#Defining_a_context
>
> > And it does work, but there's also a problem. When user input
> > http://ip:8080/portal.do visit the site and login, the Root path
> > can not get the session. In other words, he was asked to re-login
> > when he open some page from portal.do such as
> > http://ip:8080/a.jsp. Is there anything i can solve this?
>
> No. Even with single-sign-on, all web applications have separate
> HttpSessions. If you want to share state between them, you'll need to
> implement something yourself.
>
> Suggestions: RDBMS, memcached, etc.
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1
> Comment: GPGTools - http://gpgtools.org
>
> iQIcBAEBCAAGBQJUuIR1AAoJEBzwKT+lPKRYPCQP/1BWAFaETpQhafukSI2tjHl4
> Ke5ab46WKurVgqWGmnM+/kGq+QfDs3+y15qKIHnTZUyZCsctedJtFS5btxJI8NTY
> ef32w+dfK1+vSY7YLrYV6gzIaBVTnm20dC90eFf9JJ1xYcU5oLUzVL2rMtt7r+zc
> ytYpxoygRp37T+NownZA2NTfmzBSw6et7pwE5+ruSPORuDBuxeVZbDaHBRZKllzf
> a6iTfZdnPZUg5wdGPDeNePGFdJhcK+7e4GJuJRqCXmvlHg/ZX4x2hBlvdukhBl6S
> wcHVz6lLN6sgsspBGIGfJdRznUMR5tiKPnvNP7ONii+HI9g7615GFJJoytp3lzZM
> Y1smofyidPxYIVxsJwgiGdOf7MORv8tvBi6TY7qDnXAZr0MSN9W5UgG0ymRBT0/L
> VoeF/Zu5opFR7+bh3mjb7CzfTz9qYkYgaqeohjWUxbo/4H8e7foUBTWiZm7YoQWt
> /em2R4W0a2sCNmzxVtmCPAyE170FxHw28mdDvbPzGpcJg29yaVrg1W1HfrcAYuZT
> 0j5FriK4d5w5JZfaj8yjZ5dU736SDFhB06KzqUUooeQPBKjkxoawOXm8ZtFXQqrF
> kN6vCRbRoz70Uw6jNVKyyaS/MJgmsUW16I8w+bFZ/6v+ZltYFXVDmUx/HqdeYbZo
> fbNtMqa7thiSalxKmIfk
> =MBca
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: how should i configure to use one session

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

Joshua,

On 1/15/15 9:00 PM, Joshua Wang wrote:
> I'm using tomcat 6, and i have an application deployed into webapps
> and re-named ROOT, so users can visit using http://ip:8080/. But i
> need to configure that when users input http://ip:8080/portal.do
> and http://ip:8080/csmis also can visit the same site. So i added
> <Context> into server.xml like below: <Context  path="/portal.do"
> docBase="ROOT"></Context> <Context  path="/csmis"
> docBase="ROOT"></Context>

You should not configure web applications in server.xml. Instead,
deploy them properly:
http://tomcat.apache.org/tomcat-6.0-doc/config/context.html#Defining_a_context

> And it does work, but there's also a problem. When user input 
> http://ip:8080/portal.do visit the site and login, the Root path
> can not get the session. In other words, he was asked to re-login
> when he open some page from portal.do such as
> http://ip:8080/a.jsp. Is there anything i can solve this?

No. Even with single-sign-on, all web applications have separate
HttpSessions. If you want to share state between them, you'll need to
implement something yourself.

Suggestions: RDBMS, memcached, etc.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org

iQIcBAEBCAAGBQJUuIR1AAoJEBzwKT+lPKRYPCQP/1BWAFaETpQhafukSI2tjHl4
Ke5ab46WKurVgqWGmnM+/kGq+QfDs3+y15qKIHnTZUyZCsctedJtFS5btxJI8NTY
ef32w+dfK1+vSY7YLrYV6gzIaBVTnm20dC90eFf9JJ1xYcU5oLUzVL2rMtt7r+zc
ytYpxoygRp37T+NownZA2NTfmzBSw6et7pwE5+ruSPORuDBuxeVZbDaHBRZKllzf
a6iTfZdnPZUg5wdGPDeNePGFdJhcK+7e4GJuJRqCXmvlHg/ZX4x2hBlvdukhBl6S
wcHVz6lLN6sgsspBGIGfJdRznUMR5tiKPnvNP7ONii+HI9g7615GFJJoytp3lzZM
Y1smofyidPxYIVxsJwgiGdOf7MORv8tvBi6TY7qDnXAZr0MSN9W5UgG0ymRBT0/L
VoeF/Zu5opFR7+bh3mjb7CzfTz9qYkYgaqeohjWUxbo/4H8e7foUBTWiZm7YoQWt
/em2R4W0a2sCNmzxVtmCPAyE170FxHw28mdDvbPzGpcJg29yaVrg1W1HfrcAYuZT
0j5FriK4d5w5JZfaj8yjZ5dU736SDFhB06KzqUUooeQPBKjkxoawOXm8ZtFXQqrF
kN6vCRbRoz70Uw6jNVKyyaS/MJgmsUW16I8w+bFZ/6v+ZltYFXVDmUx/HqdeYbZo
fbNtMqa7thiSalxKmIfk
=MBca
-----END PGP SIGNATURE-----

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