Runtime components : Channels components : Mobile Channel : Tasks : Establishing session : Establishing session in the server side
  
Establishing session in the server side
To establish session in the server side, perform the following steps:
1 Define startup operation CreateSessionOpStep, which is defined in btt.xml:
<?xml version="1.0" encoding="UTF-8"?>
<CreateSessionOpStep.xml>
<operation id="CreateSessionOperation" context="myContext" implClass="com.ibm.btt.mobile.
operation.CreateSessionOperation"></operation>
<kColl id="myCtxData">
<field id="test" />
</kColl>
<context id="myContext" type="op">
<refKColl refId="myCtxData" />
</context>
</CreateSessionOpStep.xml>
2 Implement startup operation CreateSessionOpStep:
package com.ibm.btt.mobile.operation;
import java.io.ObjectOutput;
import java.util.Enumeration;
import com.ibm.btt.base.BTTServerOperation;
import com.ibm.btt.base.Context;
import com.ibm.btt.base.ContextFactory;
import com.ibm.btt.http.WebChannelContext;
@SuppressWarnings("serial")
public class CreateSessionOperation extends BTTServerOperation {
@Override
public void execute() throws Exception {
Context root = ContextFactory.getRoot();
if (root == null) {
System.out.println("Creating root ctx");
root = ContextFactory.createContext("branchServer", false);
}

Context sessionCtx = ContextFactory.createContext("sessionCtx", false);

sessionCtx.setValueAt("sessionID", WebChannelContext.getChannelSession().getId());
sessionCtx.chainTo(root);

Context ctx = getContext();

ctx.chainTo(sessionCtx);

}
}
Go up to
Establishing session