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.
What API(s) and/or code components does this sample highlight?
This sample leverages the HttpServlet API.
How does this sample leverage the API(s) and/or code component?
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.
Where Is This Sample?
There are three different versions of this sample, each built with a different build tool: