WebSphere eXtreme Scale Administration Guide > Configure WebSphere eXtreme Scale > Cache integration > HTTP session management > Configuring the HTTP session manager with WebSphere Application Server Community Edition



Use WebSphere eXtreme Scale for replication of session state in WebSphere Application Server Community Edition


Every Web application that is deployed to WebSphere Application Server Community Edition requires compliance with the Java™ Platform, Enterprise Edition specification, along with the geronimo-web.xml descriptor file. This file contains access and dependency information specific to the runtime environment for WebSphere Application Server Community Edition. To allow a Java EE Web application to use the session replication feature of WebSphere eXtreme Scale, the Web application must supply data about the eXtreme Scale plug-in as and session-specific attributes.


Before you begin

This process is simple enough to create on any operating system, without an IDE or utilities.

You can set up a basic Web application that uses the session persistence later in eXtreme Scale, which counts and stores the number of times a user has accessed a particular servlet.


Procedure

  1. Create the sample Web application.

    1. Create a directory at some arbitrary location within your file system. For example, you might create a directory called app_home.

    2. Navigate to the app_home directory and create the following directory structure:

      > app_home
      --> META-INF
      --> WEB-INF
      -----> lib
      -----> classes
      

    3. From the app_home/WEB-INF directory, create a web.xml file. Copy and paste the following code into the web.xml file. Ensure that all context parameters are added to the web.xml file, or the filter might not work correctly.

      <?xml version="1.0" encoding="UTF-8"?>
      <web-app id="sample" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" 
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
              http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
          <display-name>
          sample</display-name>
          <context-param>
         
      <param-name>shareSessionsAcrossWebApps</param-name>
         
      <param-value>false</param-value>
       
      </context-param>
       
      <context-param>
           
      <param-name>sessionIDLength</param-name>
           
      <param-value>23</param-value>
       
      </context-param>
       
      <context-param>
           
      <param-name>defaultSessionTimeout</param-name>
           
      <param-value>30</param-value>
       
      </context-param>
       
      <context-param>
           
      <param-name>affinityManager</param-name>
           
      <param-value>com.ibm.ws.httpsession.NoAffinityManager</param-value>
       
      </context-param>
       
      <context-param>
           
      <param-name>useURLEncoding</param-name>
           
      <param-value>false</param-value>
       
      </context-param>
       
      <context-param>
           
      <param-name>objectGridName</param-name>
           
      <param-value>session</param-value>
       
      </context-param>
       
      <context-param>
           
      <param-name>persistenceMechanism</param-name>
           
      <param-value>ObjectGridStore</param-value>
       
      </context-param>
       
      <filter>
           
      <filter-name>HttpSessionFilter</filter-name>
           
      <filter-class>com.ibm.ws.httpsession.HttpSessionFilter</filter-class>
       
      </filter>
       
      <filter-mapping>
           
      <filter-name>HttpSessionFilter</filter-name>
           
      <url-pattern>/*</url-pattern>
       
      </filter-mapping>
          <servlet>
              <description>
              </description>
              <display-name>
              SampleServlet</display-name>
              <servlet-name>SampleServlet</servlet-name>
              <servlet-class>
              SampleServlet</servlet-class>
          </servlet>
          <servlet-mapping>
              <servlet-name>SampleServlet</servlet-name>
              <url-pattern>/SampleServlet</url-pattern>
          </servlet-mapping>
          <welcome-file-list>
              <welcome-file>index.html</welcome-file>
              <welcome-file>index.htm</welcome-file>
              <welcome-file>index.jsp</welcome-file>
              <welcome-file>default.html</welcome-file>
              <welcome-file>default.htm</welcome-file>
              <welcome-file>default.jsp</welcome-file>
          </welcome-file-list>
      </web-app>
      

    4. From the app_home/WEB-INF directory, create a geronimo-web.xml file. Copy and paste the following code into the geronimo-web.xml file:

      <?xml version="1.0" encoding="UTF-8"?>
      <web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.1"
          xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.1" 
          xmlns:sec="http://geronimo.apache.org/xml/ns/security-1.1"
          xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.1">
          <sys:environment>
              <sys:moduleId>
                  <sys:groupId>com.ibm.websphere.objectgrid</sys:groupId>
                  <sys:artifactId>sample</sys:artifactId>
                  <sys:version>1.0</sys:version>
                  <sys:type>war</sys:type>
              </sys:moduleId>
              <sys:dependencies>
                  <sys:dependency>
                      <sys:groupId>com.ibm.websphere.objectgrid
                      </sys:groupId>
                      <sys:artifactId>session</sys:artifactId>
                      <sys:version>1.0</sys:version>
                      <sys:type>jar</sys:type>
                  </sys:dependency>
              </sys:dependencies>
          </sys:environment>
          <context-root>/sample</context-root>
      </web-app>
      

    5. Place the SampleServlet.class attached below in the WEB-INF/classes directory.

    6. Navigate to the app_home directory.

    7. Run the following command to package the Web archive (WAR) file:

      jar -cf sample.war
      

    8. Your Web application is now ready to be deployed.

  2. Deploy the Web application.

    1. Login to the WebSphere Application Server Community Edition home page at the specified hostname:port. By default, the home page is: http://localhost:8080/.

    2. Click Administrative Console.

    3. Type the username and password, then click OK. By default, the credentials are:

      • user name: System

      • password: Manager

    4. Select Applications > Deploy New in the left-hand menu.

    5. Click Browse to the right of Archive, then select the sample.war file you created in the previous section.

    6. Leave the Plan field blank, because you bundled the plan with the Web application.

    7. Select Start App after Install, then click Install.
    After the application installs, a message displays that says the installation was successful.

  3. Test the application.

    1. Navigate to the /sample/SampleServlet context root to test the application. By default, the context root is: http://localhost:8080/sample/SampleServlet.

    2. You should see the number of times you have visited this servlet, followed by the HttpSession implementation. It should read HttpSessionImpl if it is using the eXtreme Scale persistence layer, or StandardSessionFacade if it is using the Web container's default session-storage mechanism.



Parent topic

Configure the HTTP session manager with WebSphere Application Server Community Edition


+

Search Tips   |   Advanced Search