Configuring Liberty for Servlet 4.0

You can configure Liberty for the Servlet 4.0 feature, which provides full support for the Servlet 4.0 specification.

About this task

To configure a Liberty server to run an application that is enabled for Servlet 4.0, add the servlet-4.0 feature.


Update the server.xml file to add the servlet-4.0 feature as shown in the following example:
  • The Servlet 4.0 feature can be used only with other Java™ EE 8 features and Java EE 7 features that do not have an equivalent Java EE 8 version. For example, you can use the jsf-2.3 feature only with Servlet 4.0, but you can use the jsp-2.3 feature with either Servlet 4.0 or Servlet 3.1.
  • The following list includes other features that require or tolerate Servlet 4.0:
    • The Java EE 7 feature jsp-2.3
    • The Java EE 7 feature websocket-1.1
  • You can choose between Servlet 3.0, Servlet 3.1, and Servlet 4.0 feature implementations for each server instance. However, consider behavior changes. If only the Servlet 4.0 feature contains a required behavior, use the Servlet 4.0 feature.
  • If behavior changes in the Servlet 4.0 feature adversely impact an existing application, use either the Servlet 3.1 feature or the Servlet 3.0 feature to preserve the existing behavior for that application.
  • You cannot use two servlet features in the same Liberty server. If two or more servlet features are configured, either directly or indirectly through other features, the program produces an error. For more information, see Servlet 4.0 behavior changes.
  • The Servlet 4.0 feature requires Java 8 at minimum.


The Servlet 4.0 feature now loads at run time.