0

Possible Duplicate:
Any way to share session state between different applications in tomcat?

How can i share a session Attribute in 2 web project in the same work space ?

i read that the session is on the server why when i go the 2nd project in the same work space i dont find any session Attribute .

i mean i cant use that in the énd project

<%
                        if(session.getAttribute("UserName") != null ){

                        %>

        do Some work 

        <% } %>

i'm usign Tomcat V7 as a server and eclipse

Community
  • 1
  • 1
Mioo
  • 11
  • 2
  • 2
    The basic answer is: you cannot share a session between two webapps. Why do you want to do that? – mkro Jun 30 '11 at 18:57
  • Also, a workspace is an Eclipse thing. It doesn't have any meaning for Tomcat, which is where the application runs. Tomcat knows about web apps, not workspaces. – JB Nizet Jun 30 '11 at 19:07
  • @ mkro : i have a web project application and web service i had a prbm with creating a hibernate in the web service and i dont have time so i finish my web application in 2nd web project , i have left one jsp file must be in the web serviceClient so i want to use a session in this jsp file to access it from the web app – Mioo Jun 30 '11 at 19:41
  • @ JB Nizet : sir go see the server.xml of tomcat and you will find the path of the work space and the path of the web project – Mioo Jun 30 '11 at 19:42

2 Answers2

1

hmmm! if you are using tomcat you can set crossContext=true in server.xml i.e.

<Context allowLinking="true" docBase="/home/appA" path="/appA" reloadable="true"  crossContext="true"/>
<Context allowLinking="true" docBase="/home/appB" path="/appB" reloadable="true" crossContext="true"/>

and then you can share the sessions, also if you can tell me the situation then I might be more helpful

mrk
  • 4,999
  • 3
  • 27
  • 42
MNet
  • 79
  • 1
  • 2
  • 7
  • i have a web project application and web service i had a prbm with creating a hibernate in the web service and i dont have time so i finish my web application in 2nd web project , i have left one jsp file must be in the web serviceClient so i want to use a session in this jsp file to access it from the web app , thank you so mutch for you answer – Mioo Jun 30 '11 at 19:32
  • sir i try this like that – Dilllllo Jul 01 '11 at 00:28
  • 1
    when i add this to server.xml the server wont start , whyyyyy? – Dilllllo Jul 01 '11 at 01:47
0

i try to do what the answer say so i change them like that

 <Context docBase="SpeedyService" path="/SpeedyService" reloadable="true" source="org.eclipse.jst.jee.server:SpeedyService" crossContext="true"/><Context docBase="HiberBarti" path="/HiberBarti" reloadable="true" source="org.eclipse.jst.jee.server:HiberBarti" crossContext="true"/><Context docBase="SpeedyServiceClient" path="/SpeedyServiceClient" reloadable="true" source="org.eclipse.jst.jee.server:SpeedyServiceClient" crossContext="true"/></Host>

but i found a 2nd file service.xml in my work space i didnt change

<Context docBase="F:\workspacetravailProject\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\ROOT" path="" reloadable="false"/><Context docBase="F:\workspacetravailProject\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\SpeedyService" path="/SpeedyService" reloadable="true" source="org.eclipse.jst.jee.server:SpeedyService"/><Context docBase="F:\workspacetravailProject\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\HiberBarti" path="/HiberBarti" reloadable="true" source="org.eclipse.jst.jee.server:HiberBarti"/><Context docBase="F:\workspacetravailProject\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\SpeedyServiceClient" path="/SpeedyServiceClient" reloadable="true" source="org.eclipse.jst.jee.server:SpeedyServiceClient"/></Host>
David
  • 47
  • 1
  • 3
  • 16