1) open contex.xml file in tomcat and ebable crossContext=true
<Context crossContext="true" >
<WatchedResource>WEB-INF/web.xml</WatchedResource>
</Context>
2) Open server.xml file and ( Note : add your apps context if not available)
<Context docBase="webapp1" path="/webapp1" reloadable="true" source="org.eclipse.jst.j2ee.server:webapp1">
<Parameter name="app2SSOUrl" value="http://IP:8080/webapp2/SSOlogin" override="false"/>
</Context>
<Context docBase="webapp2" path="/webapp2" reloadable="true" source="org.eclipse.jst.j2ee.server:webapp2">
<Parameter name="app1SSOUrl" value="http://IP:8080/webapp1/SSOlogin" override="false"/>
</Context>
WEBAPP1 SERVLET
ServletContext webapp1Context = ((HttpServletRequest) request).getSession().getServletContext();
String webApp2SSOUrl = webapp2Context.getInitParameter("app2SSOUrl");
ServletContext webapp2Context = ((HttpServletRequest) request).getSession().getServletContext().getContext("webapp2");
WEBAPP2 SERVLET
ServletContext webapp1Context = ((HttpServletRequest) request).getSession().getServletContext().getContext("webapp1");
ServletContext webapp2Context = ((HttpServletRequest) request).getSession().getServletContext();
String webApp1SSOUrl = webapp2Context.getInitParameter("app1SSOUrl");
In both the webapp servlet you can access the respective context object and also you can get the attributes value configured into the server.xml file's context tag. and you can take the ssourl values
and then further can proceed with your requirement.
that's it mate.
So keep visiting. Write comments. Be happy :)
<Context crossContext="true" >
<WatchedResource>WEB-INF/web.xml</WatchedResource>
</Context>
2) Open server.xml file and ( Note : add your apps context if not available)
<Context docBase="webapp1" path="/webapp1" reloadable="true" source="org.eclipse.jst.j2ee.server:webapp1">
<Parameter name="app2SSOUrl" value="http://IP:8080/webapp2/SSOlogin" override="false"/>
</Context>
<Context docBase="webapp2" path="/webapp2" reloadable="true" source="org.eclipse.jst.j2ee.server:webapp2">
<Parameter name="app1SSOUrl" value="http://IP:8080/webapp1/SSOlogin" override="false"/>
</Context>
WEBAPP1 SERVLET
ServletContext webapp1Context = ((HttpServletRequest) request).getSession().getServletContext();
String webApp2SSOUrl = webapp2Context.getInitParameter("app2SSOUrl");
ServletContext webapp2Context = ((HttpServletRequest) request).getSession().getServletContext().getContext("webapp2");
WEBAPP2 SERVLET
ServletContext webapp1Context = ((HttpServletRequest) request).getSession().getServletContext().getContext("webapp1");
ServletContext webapp2Context = ((HttpServletRequest) request).getSession().getServletContext();
String webApp1SSOUrl = webapp2Context.getInitParameter("app1SSOUrl");
In both the webapp servlet you can access the respective context object and also you can get the attributes value configured into the server.xml file's context tag. and you can take the ssourl values
and then further can proceed with your requirement.
that's it mate.
So keep visiting. Write comments. Be happy :)
No comments:
Post a Comment