title: How to use servlet with OSGi
body: <p>I want to create and deploy a web service to OSGi container. For example, publish the service to the address: </p>
  
  <pre><code>http://localhost:8080/testservice. 
  </code></pre>
  
  <p>The service generate HTML response in a servlet.</p>
  
  <p>I have searched a lot and got:</p>
  
  <pre><code>public class HelloWorldServlet extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      response.setContentType("text/html");
      PrintWriter out = response.getWriter();
      out.println("&lt;html&gt;");
      out.println("&lt;head&gt;");
      out.println("&lt;title&gt;Hola&lt;/title&gt;");
      out.println("&lt;/head&gt;");
      out.println("&lt;body bgcolor=\"white\"&gt;");
      out.println("&lt;/body&gt;");
      out.println("&lt;/html&gt;");
    }
  }
  </code></pre>
  
  <p>The tool I need to use:</p>
  
  <ol>
  <li><p>maven to create the project</p></li>
  <li><p>Fuse ESB karaf as OSGi container</p></li>
  </ol>
  
  <p>The question is that I do not know how to use Maven to create and implement such web service, like:</p>
  
  <ul>
  <li><p>how to specify <code>webapp/web.xml</code></p></li>
  <li><p>how to specify <code>pom.xml</code>: dependencies, package type, plugin</p></li>
  <li><p>how to register service: implement <code>BundlActivator</code> or configure Spring xml file</p></li>
  </ul>
  
  <p>Can anyone help me with this? Is there a detailed tutorial for newbie?</p>