Intro
This is the first article that I wrote in order to show how IMS / SIP services can be built using the SIP Servlets technology.
Session Initiation Protocol, known as SIP, is a signaling protocol that is used by next-generation applications in the telecom industry.
The articles will be based on SIP Servlets technology and I will also provide some examples in order to have you test the functionality by yourself. The examples will be coded in Java, which provides a very good platform for building SIP applications.
What do I need to move forward?
It’s actually pretty simple, there are not so many prerequisites for this tutorial. Let’s just name a few:
- first, you need an IDE to run the examples. I’m using Ericsson SDS which I find really useful.
- SIP Servlet API Specs, available here.
- SIP Protocol knowledge.
- HTTP Servlets knowledge.
- 15 minutes to get to the end of this tutorial ![]()
SIP Servlets. What are they?
The SIP Servlets are quite similar with HTTP Servlets. There are alot of good articles on the Internet talking about both SIP and HTTP Servlets. You can just quickly google for them so you can have a good understanding on how a servlet works.
A servlet is an object that receives a request and after processing it generates a response to the initial request. When using HTTP, we can process GET or POST methods inside a servlet and generate HTTP specific response messages such as “200 OK” or “404 Not Found”.When it comes to SIP, a servlet can receive a request and response at any time.
A servlet container is a specialized server that supports servlet execution. There is an open-source implementation of a SIP Application Server that I recommend, called Sailfin, which allows a developer to mix SIP Servlets and Java EE components.
OK, I got it. Let’s move on!
The great thing about the SIP Servlets is that the developer should only focus on the high-level of the application, while the actual servlet technology is taking care of SIP transactions,dialogs, message parsing or other protocol specific things. What does it mean ?
Well, I will show you how can you build a very simple SIP Redirect server with only five lines of code.
So here’s what we need to do.
First, we will create a new servlet, called RedirectServlet that extends the SipServlet defauld implementation:
public class RedirectServlet extends SipServlet {}
Once this is build, the next thing to do is to create the servlet’s init() method like this:
public void init(ServletConfig config) throws ServletException {
super.init(config);
ServletContext context = config.getServletContext();
sipFactory = (SipFactory) context
.getAttribute(”javax.servlet.sip.SipFactory”);
}
What does our Redirect Server do ? For each INVITE request that it receives, it will perform a database query (not included here) and it will answer back ith a 302 Moved Temporarily message containing a new “Contact” field. Check the below lines of code:
protected void doInvite(SipServletRequest req)
throws ServletException, IOException {
//it gets the MSISDN from the next string. sip:MSISDN@domain.com
String MSISDN = req.getRequestURI().toString().substring(req.getRequestURI().toString().indexOf(”:”)+1, req.getRequestURI().toString().indexOf(”@”));
//check the above parsing
System.out.println(”MSISDN=”+MSISDN);
//building the 302 Moved Temporarily
SipServletResponse resp = req.createResponse(302);
resp.removeHeader(”Contact”);
// database_query(MSISDN) will return a new number to be put in the Contact field
resp.addHeader(”Contact”, database_query(MSISDN)+”@otherdomain.com”);
resp.send();
}
There you go! A brand new SIP Redirect Server built in just 10 minutes.
To test the RedirectServlet, you need to use Ericsson’s SDS IDE and start a new project. The IDE has a SIP Application Server built-in so you can easily test your new servlet inside the IDE. I will upload the complete source-code of the RedirectServlet in the next coming days.
I hope this article gives you a quick start on programming SIP applications using SIP Servlets technology. Once I’ll get some spare time, I will be happy o add some more articles related to this new technology.
Interested in other articles? Read my techLog here.







te plateste ericsson pentru asta?
faptul ca apare numele ericsson acolo nu inseamna ca e reclama
Very good article, thank you!
nu ma asteptam sa gasesc informatii asa pretioase atat de aproape :))