留言板
Servlet with Osgi bundle
Hi,
How can we create servlet with liferay osgi module ? Which service class to use and how to define URL pattern for servlet ?
I looked into liferay blade sample on github but i don't see any reference available for the same.
Any pointer on this issue would be appreciated.
Thanks !
Jitendra
How can we create servlet with liferay osgi module ? Which service class to use and how to define URL pattern for servlet ?
I looked into liferay blade sample on github but i don't see any reference available for the same.
Any pointer on this issue would be appreciated.
Thanks !
Jitendra
Just build your servlet into a war and deploy using the Liferay deploy folder. You'll be able to hit the servlet from the /o/your-servlet-context sort of path.
Maybe this can be useful, it works for me in Liferay 7 / DXP
@Component(
immediate = true,
property = {
"osgi.http.whiteboard.context.path=/",
"osgi.http.whiteboard.servlet.name=my.package.name.myTest",
"osgi.http.whiteboard.servlet.pattern=/myTest/test",
},
service = Servlet.class)
public class myTest extends HttpServlet {
.......
}
Servlet URL : http://localhost:8080/o/myTest/test
@Component(
immediate = true,
property = {
"osgi.http.whiteboard.context.path=/",
"osgi.http.whiteboard.servlet.name=my.package.name.myTest",
"osgi.http.whiteboard.servlet.pattern=/myTest/test",
},
service = Servlet.class)
public class myTest extends HttpServlet {
.......
}
Servlet URL : http://localhost:8080/o/myTest/test