Servlet

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.

Figure 1: The servlet displays Hello World from the configured servlet page URL.

Figure 1: The servlet displays *Hello World* from the configured servlet page URL.

Figure 2: The servlet also logs info in the console.

Figure 2: The servlet also logs info in the console.

To configure the servlet in Liferay DXP, complete the following steps:

  1. Navigate to the Control PanelConfigurationServer AdministrationLog Levels.

  2. Select Add Category.

  3. Insert com.liferay.blade.samples.servlet.BladeServlet for the Logger Name and INFO for the Log Level.

  4. 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:

この記事は役に立ちましたか?
0人中0人がこの記事が役に立ったと言っています