본문 바로가기

WEB & WAS/WebSphere

[WebSphere] Context간 세션 공유

반응형

개요

기본적으로 세션은 Context(웹모듈)단위로만 공유가 가능하다. Shered Session Context 기능을 이용하여 컨텍스트간 세션 공유방법에 대해서 알아보도록 하자

테스트 환경

WebSphere 9.0.5.1

 

Shered Session Context 기능을 사용하기 위해서는 애플리케이션을 EAR 형태로 배포해야만 Shered Session Context 기능을 사용할수가 있다.

여기에 myapp.war, myapp2.war 라는 웹모듈이 있을 경우 두 웹모듈사이에 세션을 공유하기 위해서는 META-INF/ibm-application-ext.xml <shared-session-context value="true"/> 추가하면 된다

[그림 1] EAR 구조

1. EAR 파일 생성

shell> mkdir EAR

shell> cd EAR

shell> cp myapp.war EAR/

shell> cp myapp2.war EAR/

shell> mkdir META-INF

shell> cd META-INF

shell> vi ibm-application-ext.xml

<?xml version="1.0" encoding="UTF-8"?> 

    <application-ext xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

      xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-application-ext_1_0.xsd" version="1.0">

    <shared-session-context value="true"/>

</application-ext>

shell> jar cvf  sharedContext.ear META-INF/ myapp.war myapp.war

생성된 EAR 어플리케이션 파일을 배포하면 된다.

참고 : WebSphere 애플리케이션 배포 참조

반응형