Tutorial:SIP Servlet Abstractions

From Wesip

From Wesip

The SIP Servlet API is comprised of several abstractions in the form of classes and interfaces all of them under the package javax.servlet.sip. Just like the HTTP Servlet API the SIP servlet API is an specialization of the generic servlet API.

  • javax.servlet
    • javax.servlet.http
    • javax.servlet.sip

Following this pattern SipServlet extends GenericServlet as a SIP specialization. The same applies for SipServletRequest extending ServletRequest, SipServletResponse extending ServletResponse or SipServletMessage extending ServletMessage.

The main classes and interfaces used in SIP Servlet development

Acts as a sandbox inside the container where applications are executed. Every application has its own context where all its servlets run. Since every context has its own class loader the isolation between applications is garanteed. Servlets of an application use the context primarily as a mechanism for communication between them.

 Converged Context

The base class that developers subclass to implement their servlets. Defines the lifecycle methods (init,destroy) as well as the message handling methods (doRequest, doResponse, ...) and implements their default behaviour.
SipServletRequest and SipServletResponse 
Encapsulate SIP requests and response messages respectively. Both provides access to the relevant request and response information as well handy methods for their process like createResponse, createACK, createCancel, getProxy or send.
Defines a number of methods which are common to SipServletRequest and SipServletResponse, for example setters and getters for message headers and content.
SipSessions are used to maintain dialog state. Every message belongs to a SipSession which can be seen as the representation of the SIP dialog or call leg the message is engaged in.
In many SIP applications like B2BUA an incoming message sets up a dialog that leads to the initiation of other dialogs each of them represented by their own SipSession. Despite those SipSessions are independent they all are related to the same execution of the service. We could think of them as an application instance. The SipApplicationSession represents the application instance and as such holds references to all the SipSessions as well as HttpSessions in the case of converged applications. It also provides methods to store application instance data.


Used to create new application sessions, requests, addresses and URI objects. Servlets obtain a reference to it through a ServletContext attribute with name javax.servlet.sip.SipFactory.
Represents a proxy operation. Offers methods to configure several proxy aspects like whether it should be stateless or stateful, parallel or sequential, record routed or not. Setting the proxy supervision flag configures how controlling servlet is to be invoked for subsequent events like incoming responses, CANCELs and ACKs, relating to this proxying transaction.

<< SIP Servlet Programming model | SIP Servlet LifeCycle and methods >>