Controlling write operations

You can manually control when modified session data is written out to the database or to another WAS instance by using the sync() method in the com.ibm.websphere.servlet.session.IBMSession interface, which extends the javax.servlet.http.HttpSession interface. By calling the sync() method from the service() method of a servlet, you send any changes in the session to the external location. When manual updateis selected as the write frequency mode, session data changes are written to an external location only if the application calls the sync() method. If the sync() method is not called, session data changes are lost when a session object leaves the server cache. When end of service servlet or time based is the write frequency mode, the session data changes are written out whenever the sync() method is called. If the sync() method is not called, changes are written out at the end of service method or on a time interval basis based on the write frequency mode selected.

   IBMSession iSession = (IBMSession) request.getSession();
   iSession.setAttribute("name", "Bob");
   
   //force write to external store
   iSession.sync( )

 

See Also

Tuning session management