Session

J2EE doesn't not allow the share of sessions across different web application. Is there a way i could make it so it allows share of sessions?so my web application would share sessions with one of my servlet. or is there an alternative way to get around this? thank you
[283 byte] By [Mike1988a] at [2007-11-26 18:55:42]
# 1

> there a way i could

> make it so it allows share of sessions?so my web

> application would share sessions with one of my

> servlet.

I think you are misundestanding what servlets are, they share the same objects with you other session obejcts, that if they bellong to the same user(session). You cannot share sessions, if you need any date to be shared across sessions, use context instead.

MeTitus

Me_Titusa at 2007-7-9 20:34:10 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
thank you for the advice. should i change something in the web.xml file of my servlet to solve this problemthank you
Mike1988a at 2007-7-9 20:34:10 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

I don't know which web server you are using, because you haven't mentioned it.

But incase you are using Tomcat 5.x or higher you can set crossContext="true"

See here: for details regarding the crossContext attribute:

http://tomcat.apache.org/tomcat-5.0-doc/config/context.html

<Context docBase="C:\dev\projects\ProjectName\__source"

privileged="false" antiResourceLocking="false" antiJARLocking="false" crossContext="true" reloadable="true" cachingAllowed="false" >

</Context>

If you are using a different web server (not Tomcat) then refer the documentation for that webserver for the equivalent of crossContext.

All web application servers use Tomcat as a base reference, so most of them will be similar to Tomcat.

FYI , the context file for your application will be located under:

C:\dev\apache-tomcat-5.5.12\conf\Catalina\localhost

Where : C:\dev\apache-tomcat-5.5.12 is the directory where you installed Tomcat or another web server.

appy77a at 2007-7-9 20:34:10 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

Thank you so much i am in fact using tomcat as my servlet container. i'm using jboss+tomcat bundle . um... Is the fellowing line

<Context docBase="C:\dev\projects\ProjectName\__source"

privileged="false" antiResourceLocking="false" antiJARLocking="false" crossContext="true" reloadable="true" cachingAllowed="false" >

</Context>

coded in the service.xml of tomcat or do i need to specify it in my deployment descriptor

thanks you

Mike1988a at 2007-7-9 20:34:10 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

Hi Mike,

On a clean install of Tomcat 5.x the following is supposed to be place inside a *context* file for your application directly under:

<TOMCAT_FOLDER>\conf\Catalina\localhost\

<Context docBase="C:\dev\projects\ProjectName\__source"

privileged="false" antiResourceLocking="false" antiJARLocking="false" crossContext="true" reloadable="true" cachingAllowed="false" >

</Context>

If your application say, is named HRApplication and if you access your application like this http://localhost:8080/HRApplication/ then,

HRApplication is known as the *context* , so one would normally create an XML file called HRApplication.xml (same as the name of the context) and place it under <TOMCAT_FOLDER>\conf\Catalina\localhost\

On the other hand if you access your application simply on the ROOT context that is http://localhost:8080/ , then you would create a file called ROOT.xml and place it under <TOMCAT_FOLDER>\conf\Catalina\localhost\

By having the above set-up, it gives you the flexibility to have your project's working directory outside Tomcat's webapps folder. This kind of a set up is very convenient in the development environment.

~~~~~~~~~~~~~~~~~~~~~~~~

But if you have configured your application in server.xml , and then you also have a context file under <TOMCAT_FOLDER>\conf\Catalina\localhost\ there might possibly be some conflicts

Instead of setting that crossContext option in context.xml you may have to set it in server.xml - unfortunately I don't know much about configuring server.xml

But, I encourage you to check with the Tomcat User Mailing List here:

http://tomcat.apache.org/lists.html the list members would be able to help you better.

appy77a at 2007-7-9 20:34:10 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...