You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Mike Cronin <mi...@fax.com> on 2007/09/06 01:05:01 UTC

Different sessions between JSP and Servlets...

Okay, I have the following structure.

 

$CATLINA-HOME\webapps\a_subfolder\my_root\

 

Within my_root there are a number of subfolders that contain various
applications i.e. login, admin, reports and my WEB-INF.

 

The first thing I need to make sure of is that I am using the correct
terminology. Correct me if I'm wrong, but the structure I defined is a
<Context>, correct?

 

The problem I am having is that my JSP pages are receiving a different
session than my servlets. Because all of these applications exist within a
<Context>, I'm confused as to why the sessionIDs would be different.

 

My <Host> element is defined as follows (the only Context referenced is the
default).

 

      <Host name="my_site.com" appBase="webapps\a_subfolder\my_root\">

        <Context path="" docBase="\">

          <ResourceLink name="jdbc/OracleDS" global="OracleDataSource"
type="javax.sql.DataSource"/>

        </Context>

      </Host>

 

I am obviously missing something important here, and could really use some
enlightenment (or a slap upside the head).

 

Thanks in advance!

 

Mike

 

Fax.com

"The New Way To Fax!"

 <http://www.fax.com/> www.fax.com

 

Confidential: This electronic message and all contents contain information
from Fax.com, Inc. which may be privileged, confidential or otherwise
protected from disclosure. The information is intended to be for the
addressee(s) only.  If you are not an addressee, any disclosure, copy,
distribution or use of the contents of this message is prohibited.  If you
have received this electronic message in error, please notify the sender by
reply e-mail and destroy the original message and all copies. Thank you.

 


RE: Different sessions between JSP and Servlets...

Posted by Mike Cronin <mi...@fax.com>.
We'll do. Thanks.

Fax.com
"The New Way To Fax!"
www.fax.com
 
Confidential: This electronic message and all contents contain information
from Fax.com, Inc. which may be privileged, confidential or otherwise
protected from disclosure. The information is intended to be for the
addressee(s) only.  If you are not an addressee, any disclosure, copy,
distribution or use of the contents of this message is prohibited.  If you
have received this electronic message in error, please notify the sender by
reply e-mail and destroy the original message and all copies. Thank you.

-----Original Message-----
From: Hassan Schroeder [mailto:hassan.schroeder@gmail.com] 
Sent: Wednesday, September 05, 2007 5:30 PM
To: Tomcat Users List
Subject: Re: Different sessions between JSP and Servlets...

On 9/5/07, Mike Cronin <mi...@fax.com> wrote:

> I definitely want this set up correctly, and I do intend to move the
> <Context> elements out of the server.xml, but I have not been able to
> successfully do so as none of the applications want to load from the
> context.xml.

That's suspicious in and of itself, but if I were you I'd start with a
clean install and make sure it works; then replace the default
Context in webapps (the directory named ROOT) with your own.

-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

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


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


Re: Different sessions between JSP and Servlets...

Posted by Hassan Schroeder <ha...@gmail.com>.
On 9/5/07, Mike Cronin <mi...@fax.com> wrote:

> I definitely want this set up correctly, and I do intend to move the
> <Context> elements out of the server.xml, but I have not been able to
> successfully do so as none of the applications want to load from the
> context.xml.

That's suspicious in and of itself, but if I were you I'd start with a
clean install and make sure it works; then replace the default
Context in webapps (the directory named ROOT) with your own.

-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

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


RE: Different sessions between JSP and Servlets...

Posted by Mike Cronin <mi...@fax.com>.
Thanks for the reply Hassan.

I definitely want this set up correctly, and I do intend to move the
<Context> elements out of the server.xml, but I have not been able to
successfully do so as none of the applications want to load from the
context.xml.

Mike

Fax.com
"The New Way To Fax!"
www.fax.com
 
Confidential: This electronic message and all contents contain information
from Fax.com, Inc. which may be privileged, confidential or otherwise
protected from disclosure. The information is intended to be for the
addressee(s) only.  If you are not an addressee, any disclosure, copy,
distribution or use of the contents of this message is prohibited.  If you
have received this electronic message in error, please notify the sender by
reply e-mail and destroy the original message and all copies. Thank you.

-----Original Message-----
From: Hassan Schroeder [mailto:hassan.schroeder@gmail.com] 
Sent: Wednesday, September 05, 2007 4:16 PM
To: Tomcat Users List
Subject: Re: Different sessions between JSP and Servlets...

On 9/5/07, Mike Cronin <mi...@fax.com> wrote:

> $CATLINA-HOME\webapps\a_subfolder\my_root\

> Within my_root there are a number of subfolders that contain various
> applications i.e. login, admin, reports and my WEB-INF.

1) defining Contexts within server.xml is discouraged,
2) appBase and docBase must not be the same,
3) so,  if you want to define your appBase as this:

    <Host name="my_site.com" appBase="webapps\a_subfolder\"/>

:: create a META-INF/context.xml file within your Context with
 <Context>
    <ResourceLink name="jdbc/OracleDS"
        global="OracleDataSource"
        type="javax.sql.DataSource"/>
</Context>

NOTE: no path attribute and no docBase attribute should be used
in this case.

HTH,
-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

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


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


Re: Different sessions between JSP and Servlets...

Posted by Hassan Schroeder <ha...@gmail.com>.
On 9/5/07, Mike Cronin <mi...@fax.com> wrote:

> $CATLINA-HOME\webapps\a_subfolder\my_root\

> Within my_root there are a number of subfolders that contain various
> applications i.e. login, admin, reports and my WEB-INF.

1) defining Contexts within server.xml is discouraged,
2) appBase and docBase must not be the same,
3) so,  if you want to define your appBase as this:

    <Host name="my_site.com" appBase="webapps\a_subfolder\"/>

:: create a META-INF/context.xml file within your Context with
 <Context>
    <ResourceLink name="jdbc/OracleDS"
        global="OracleDataSource"
        type="javax.sql.DataSource"/>
</Context>

NOTE: no path attribute and no docBase attribute should be used
in this case.

HTH,
-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

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


RE: Different sessions between JSP and Servlets...

Posted by Mike Cronin <mi...@fax.com>.
Thanks Christopher.

At this point, the context is coded within the server.xml. I understand that
the context should be placed within a context.xml file within a META-INF,
but doing so has been giving me problems thus far (something I plan to
tackle here shortly).

As for the JSP/Servlet session issues discussed within this thread, I
believe that I have them resolved.

Thanks once again for your valued input.

Best regards,

Mike
 
Fax.com
"The New Way To Fax!"
www.fax.com
 
Confidential: This electronic message and all contents contain information
from Fax.com, Inc. which may be privileged, confidential or otherwise
protected from disclosure. The information is intended to be for the
addressee(s) only.  If you are not an addressee, any disclosure, copy,
distribution or use of the contents of this message is prohibited.  If you
have received this electronic message in error, please notify the sender by
reply e-mail and destroy the original message and all copies. Thank you.

-----Original Message-----
From: Christopher Schultz [mailto:chris@christopherschultz.net] 
Sent: Thursday, September 06, 2007 2:30 PM
To: Tomcat Users List
Subject: Re: Different sessions between JSP and Servlets...

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mike,

Mike Cronin wrote:
> <Context path="" docBase="\my_root\">

You should remove both of these attributes from your <Context> in
context.xml. As mentioned before in this thread, they are at best
ignored, and at worst confused by Tomcat or anyone looking at the file.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG4HFw9CaO5/Lv0PARAtpCAJwOh4xIRxFIa6gNWZSfYACU04r+3wCeOY1a
q3dTB8HeNvlJ/2gv9htG4kI=
=uZFf
-----END PGP SIGNATURE-----

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


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


Re: Different sessions between JSP and Servlets...

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

Mike,

Mike Cronin wrote:
> <Context path="" docBase="\my_root\">

You should remove both of these attributes from your <Context> in
context.xml. As mentioned before in this thread, they are at best
ignored, and at worst confused by Tomcat or anyone looking at the file.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG4HFw9CaO5/Lv0PARAtpCAJwOh4xIRxFIa6gNWZSfYACU04r+3wCeOY1a
q3dTB8HeNvlJ/2gv9htG4kI=
=uZFf
-----END PGP SIGNATURE-----

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


RE: Different sessions between JSP and Servlets...

Posted by Mike Cronin <mi...@fax.com>.
Hey Mark,

Your question as well as a previous post to another user in which you made
the point that the appBase should never point to a root directory helped me
resolve this and another JSP issue I was having. The change follows...

<Host name="my_site.com" appBase="webapps\a_subfolder\">

<Context path="" docBase="\my_root\">

I cannot thank you and Hassan enough for your assistance with this issue.

My very best regards,

Mike Cronin

Fax.com
"The New Way To Fax!"
www.fax.com
 
Confidential: This electronic message and all contents contain information
from Fax.com, Inc. which may be privileged, confidential or otherwise
protected from disclosure. The information is intended to be for the
addressee(s) only.  If you are not an addressee, any disclosure, copy,
distribution or use of the contents of this message is prohibited.  If you
have received this electronic message in error, please notify the sender by
reply e-mail and destroy the original message and all copies. Thank you.

-----Original Message-----
From: Mike Cronin [mailto:mike.cronin@fax.com] 
Sent: Thursday, September 06, 2007 11:41 AM
To: 'Tomcat Users List'
Subject: RE: Different sessions between JSP and Servlets...

<Host name="my_site.com" appBase="webapps\a_subfolder\my_root\">

<Context path="" docBase="\">

The only <Context> I reference (whether right or wrong) is the default
Context shown above. As coded, all applications successfully load using the
default Context, but I'm not able to pass session variables between my
servlets and JSPs.

Thanks for your reply Mark.

Mike
 
Fax.com
"The New Way To Fax!"
www.fax.com
 
Confidential: This electronic message and all contents contain information
from Fax.com, Inc. which may be privileged, confidential or otherwise
protected from disclosure. The information is intended to be for the
addressee(s) only.  If you are not an addressee, any disclosure, copy,
distribution or use of the contents of this message is prohibited.  If you
have received this electronic message in error, please notify the sender by
reply e-mail and destroy the original message and all copies. Thank you.

-----Original Message-----
From: Mark Thomas [mailto:markt@apache.org] 
Sent: Wednesday, September 05, 2007 7:37 PM
To: Tomcat Users List
Subject: Re: Different sessions between JSP and Servlets...

Mike Cronin wrote:
> I started from a clean install and continue to encounter the issue where
my
> JSP pages are not exposed to the session variables being set from within
my
> servlets. I believe that my <Host> element is set up correctly as I can
get
> to all of my site content as desired.

What values are you using for appBase and docBase?

Mark

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


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


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


RE: Different sessions between JSP and Servlets...

Posted by Mike Cronin <mi...@fax.com>.
<Host name="my_site.com" appBase="webapps\a_subfolder\my_root\">

<Context path="" docBase="\">

The only <Context> I reference (whether right or wrong) is the default
Context shown above. As coded, all applications successfully load using the
default Context, but I'm not able to pass session variables between my
servlets and JSPs.

Thanks for your reply Mark.

Mike
 
Fax.com
"The New Way To Fax!"
www.fax.com
 
Confidential: This electronic message and all contents contain information
from Fax.com, Inc. which may be privileged, confidential or otherwise
protected from disclosure. The information is intended to be for the
addressee(s) only.  If you are not an addressee, any disclosure, copy,
distribution or use of the contents of this message is prohibited.  If you
have received this electronic message in error, please notify the sender by
reply e-mail and destroy the original message and all copies. Thank you.

-----Original Message-----
From: Mark Thomas [mailto:markt@apache.org] 
Sent: Wednesday, September 05, 2007 7:37 PM
To: Tomcat Users List
Subject: Re: Different sessions between JSP and Servlets...

Mike Cronin wrote:
> I started from a clean install and continue to encounter the issue where
my
> JSP pages are not exposed to the session variables being set from within
my
> servlets. I believe that my <Host> element is set up correctly as I can
get
> to all of my site content as desired.

What values are you using for appBase and docBase?

Mark

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


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


Re: Different sessions between JSP and Servlets...

Posted by Mark Thomas <ma...@apache.org>.
Mike Cronin wrote:
> I started from a clean install and continue to encounter the issue where my
> JSP pages are not exposed to the session variables being set from within my
> servlets. I believe that my <Host> element is set up correctly as I can get
> to all of my site content as desired.

What values are you using for appBase and docBase?

Mark

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


RE: Different sessions between JSP and Servlets...

Posted by Mike Cronin <mi...@fax.com>.
I started from a clean install and continue to encounter the issue where my
JSP pages are not exposed to the session variables being set from within my
servlets. I believe that my <Host> element is set up correctly as I can get
to all of my site content as desired.

Have you experienced this? Your input is most appreciated.

Best regards,

Mike
 
Fax.com
"The New Way To Fax!"
www.fax.com
 
Confidential: This electronic message and all contents contain information
from Fax.com, Inc. which may be privileged, confidential or otherwise
protected from disclosure. The information is intended to be for the
addressee(s) only.  If you are not an addressee, any disclosure, copy,
distribution or use of the contents of this message is prohibited.  If you
have received this electronic message in error, please notify the sender by
reply e-mail and destroy the original message and all copies. Thank you.

-----Original Message-----
From: Mike Cronin [mailto:mike.cronin@fax.com] 
Sent: Wednesday, September 05, 2007 4:05 PM
To: users@tomcat.apache.org
Subject: Different sessions between JSP and Servlets...

Okay, I have the following structure.

 

$CATLINA-HOME\webapps\a_subfolder\my_root\

 

Within my_root there are a number of subfolders that contain various
applications i.e. login, admin, reports and my WEB-INF.

 

The first thing I need to make sure of is that I am using the correct
terminology. Correct me if I'm wrong, but the structure I defined is a
<Context>, correct?

 

The problem I am having is that my JSP pages are receiving a different
session than my servlets. Because all of these applications exist within a
<Context>, I'm confused as to why the sessionIDs would be different.

 

My <Host> element is defined as follows (the only Context referenced is the
default).

 

      <Host name="my_site.com" appBase="webapps\a_subfolder\my_root\">

        <Context path="" docBase="\">

          <ResourceLink name="jdbc/OracleDS" global="OracleDataSource"
type="javax.sql.DataSource"/>

        </Context>

      </Host>

 

I am obviously missing something important here, and could really use some
enlightenment (or a slap upside the head).

 

Thanks in advance!

 

Mike

 

Fax.com

"The New Way To Fax!"

 <http://www.fax.com/> www.fax.com

 

Confidential: This electronic message and all contents contain information
from Fax.com, Inc. which may be privileged, confidential or otherwise
protected from disclosure. The information is intended to be for the
addressee(s) only.  If you are not an addressee, any disclosure, copy,
distribution or use of the contents of this message is prohibited.  If you
have received this electronic message in error, please notify the sender by
reply e-mail and destroy the original message and all copies. Thank you.

 



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