Servlets are Java objects that run on an HTTP server and change dynamically the HTTP content in response to client requests. Servlets must be written according to the Java Servlet API from Sun Microsystems (now Oracle). The Servlet Engine of the HTTP Bundle supports the Java Servlet bundle which contains the Java Servlet API classes.
You should register a servlet as the OSGi HTTP Service Specification describes. The code example below uses the components, created in Listing 1. above, and registers a servlet (MyServlet) with the HTTP Service.
import javax.servlet.http.HttpServlet;
// Obtaining the HTTP Service from the OSGi framework
. . .
// Registering a servlet
MyServlet servlet = new MyServlet();
httpServ.registerServlet("/myServlet", servlet, httpContext);
. . .
By default, a newly-created HTTP session, represented by a javax.servlet.http.HttpSession object, has initial timeout (hence, inactive interval) of 1800 seconds.