The Servlet sample provides an OSGi Whiteboard Servlet in Liferay DXP. When deploying this sample and configuring the servlet, a Hello World message is displayed when accessing the servlet page URL. Log info is also outputted to your console.
To configure the servlet in Liferay DXP, complete the following steps:
Navigate to the Control Panel → Configuration → Server Administration → Log Levels.
Select Add Category.
Insert com.liferay.blade.samples.servlet.BladeServlet for the Logger Name and INFO for the Log Level.
Navigate to the http://localhost:8080/o/blade/servlet URL.
This sample leverages the HttpServlet API.
To customize this sample, modify its
com.liferay.blade.samples.servlet.BladeServlet class. This class extends the
HttpServlet class. Creating your own servlet for Liferay DXP is useful when you
need to implement servlet actions. For example, if you wanted to implement the
CMIS server by yourself with Apache Chemistry,
you would need to implement your own servlet, managing requests at a low level.
There are three different versions of this sample, each built with a different build tool: