~~Title: Using SessionContext~~ SessionContext is an object available only at the server that enables access to session information as well as certain objects related to a session during the handling of a client request. ==== Example ==== We have developed an application that reviews all existing messages in an email account and displays the number of messages. The request is initiated at the client by clicking a button. The call using a button is illustrated in [[jvx:client:gui:actions|Client Actions]] or [[jvx:communication:calling_server_action|Server Actions]] The server action accesses the mail server; the required access data is obtained from the application configuration. Sample code for the server action: /** * Returns the number of mails from a preconfigured email account. * * @return the number of mails */ public int getEmailCount() { IConfiguration cfgSession = SessionContext.getCurrentSessionConfig(); String sServer = cfgSession.getProperty("/application/email/server"); String sPort = cfgSession.getProperty("/application/email/port"); String sProtocol = cfgSession.getProperty("/application/email/protocol"); String sUser = cfgSession.getProperty("/application/email/username"); String sPwd = cfgSession.getProperty("/application/email/password"); MailCheck mcheck = new MailCheck(sServer, sPort, sProtocol); return mcheck.getMails(sUser, sPwd).size(); } Excerpt from the configuration file: ... ... servername or ip 110 pop3 username password ==== SessionContext Life Cycle ==== {{:jvx:server:lco:sessioncontext_lifecycle.png?nolink|}} ==== Additional Examples ==== SessionContext can also be used for the following: * Access session properties (e.g., application name, username, client properties) * Request the name of the current action * Access the server configuration * Use of the direct server connection * Add or remove objects related to a call