<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Writing Servlet in OSGi environment</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=111160258" />
  <subtitle>Writing Servlet in OSGi environment</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=111160258</id>
  <updated>2026-04-03T22:39:23Z</updated>
  <dc:date>2026-04-03T22:39:23Z</dc:date>
  <entry>
    <title>RE: Writing Servlet in OSGi environment</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111171366" />
    <author>
      <name>Minhchau Dang</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111171366</id>
    <updated>2018-10-08T21:01:36Z</updated>
    <published>2018-10-08T21:01:36Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;blockquote&gt;
  &lt;div class="quote-title"&gt;Hamidul Islam:&lt;/div&gt;
  &lt;div class="quote"&gt;
    &lt;div class="quote-content"&gt;
      &lt;p&gt;My question is why should I use &lt;strong&gt;slash o (i.e.,
        /o)&amp;nbsp;&lt;/strong&gt; to access the servlet. I believe this is nothing
        to do with OSGi.&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;p&gt;If you step back, Liferay still has the idea of virtual hosting,
  where you effectively mount a page to something resembling a context
  path (which is handled by &lt;a href="https://github.com/liferay/liferay-portal/blob/7.0.6-ga7/portal-impl/src/com/liferay/portal/servlet/filters/virtualhost/VirtualHostFilter.java"&gt;VirtualHostFilter&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;This effectively makes it a lot harder to add arbitrary paths, since
  you can't know in advance when page friendly URLs will conflict with
  OSGi servlet context paths (which translates to confusing errors at
  runtime, and Liferay has enough of those). So for simplicity, Liferay
  forces them all onto &lt;code&gt;/o&lt;/code&gt; and added &lt;code&gt;o&lt;/code&gt; to the
  list of &lt;code&gt;layout.friendly.url.keywords&lt;/code&gt;.&lt;/p&gt;
&lt;blockquote&gt;
  &lt;div class="quote-title"&gt;Hamidul Islam:&lt;/div&gt;
  &lt;div class="quote"&gt;
    &lt;div class="quote-content"&gt;
      &lt;p&gt;Does Liferay&amp;nbsp;have something which reads &lt;strong&gt;/o&lt;/strong&gt; and
        allows us to access the servlet?&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;p&gt;Kind of, it's actually the application server that is responsible for
  that piece, because it reads &lt;a href="https://github.com/liferay/liferay-portal/blob/7.0.6-ga7/portal-web/docroot/WEB-INF/web.xml#L308-L311"&gt;web.xml&lt;/a&gt;
  and discovers that Liferay's &lt;a href="https://github.com/liferay/liferay-portal/blob/7.0.6-ga7/portal-impl/src/com/liferay/portal/module/framework/ModuleFrameworkServletAdapter.java"&gt;ModuleFrameworkServletAdapter&lt;/a&gt;
  is mapped mapped to &lt;code&gt;/o&lt;/code&gt;. I might be missing a few steps,
  but I believe that implementation is waiting for &lt;a href="https://github.com/liferay/liferay-portal/blob/7.0.6-ga7/modules/apps/static/portal-osgi-web/portal-osgi-web-wab-extender/src/main/java/com/liferay/portal/osgi/web/wab/extender/internal/adapter/HttpAdapter.java#L116-L128"&gt;HttpAdapter&lt;/a&gt;,
  which I believe is responsible for setting up the Equinox
  &lt;code&gt;HttpServiceServlet&lt;/code&gt;, which makes everything work.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Minhchau Dang</dc:creator>
    <dc:date>2018-10-08T21:01:36Z</dc:date>
  </entry>
  <entry>
    <title>RE: Writing Servlet in OSGi environment</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111168214" />
    <author>
      <name>Narsingh Pal</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111168214</id>
    <updated>2018-10-08T13:16:01Z</updated>
    <published>2018-10-08T13:16:01Z</published>
    <summary type="html">&lt;p&gt;Hi Hamidul,&lt;/p&gt;
&lt;p&gt;You can see below  link.  It will give you some pointers &lt;/p&gt;
&lt;p&gt;
  &lt;a href="https://osgi.org/specification/osgi.cmpn/7.0.0/service.http.whiteboard.html"&gt;https://osgi.org/specification/osgi.cmpn/7.0.0/service.http.whiteboard.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;You can refer following section &lt;/p&gt;
&lt;p&gt; &amp;quot;140.2 Servlet Context entities and their relation&amp;quot;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Thanks and regards &lt;/p&gt;
&lt;p&gt;Narsingh pal &lt;/p&gt;</summary>
    <dc:creator>Narsingh Pal</dc:creator>
    <dc:date>2018-10-08T13:16:01Z</dc:date>
  </entry>
  <entry>
    <title>Writing Servlet in OSGi environment</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111160257" />
    <author>
      <name>Hamidul Islam</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111160257</id>
    <updated>2018-10-08T04:35:14Z</updated>
    <published>2018-10-08T04:35:14Z</published>
    <summary type="html">&lt;p&gt;Hi All,&lt;/p&gt;
&lt;p&gt;Liferay 7 comes with OSGi capabilities. I am exploring especially the
  OSGi features in Liferay environment. As part of the exploration, I
  have written a sample Servlet and deployed it. Everything is working
  good as expected. The &lt;strong&gt;context&lt;/strong&gt; of the servlet is
    &lt;strong&gt;store &lt;/strong&gt;and&lt;strong&gt; &lt;/strong&gt;the URL pattern of the
  servlet is &lt;strong&gt;myServlet. &lt;/strong&gt;To access the servlet I need
  use the URL like this &lt;/p&gt;
&lt;p&gt;
  &lt;strong&gt;http://localhost:8080/o/store/myServlet&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;My question is why should I use &lt;strong&gt;slash o (i.e., /o) &lt;/strong&gt;
  to access the servlet. I believe this is nothing to do with OSGi. Does
  Liferay have something which reads &lt;strong&gt;/o&lt;/strong&gt; and allows us
  to access the servlet? Can anyone help me to understand this?&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Regards &lt;/p&gt;
&lt;p&gt;Hamidul Islam &lt;/p&gt;
&lt;p&gt;Author: &lt;a href="http://www.proliferay.com"&gt;www.proliferay.com&lt;/a&gt; &lt;/p&gt;</summary>
    <dc:creator>Hamidul Islam</dc:creator>
    <dc:date>2018-10-08T04:35:14Z</dc:date>
  </entry>
</feed>
