Class Servlets

java.lang.Object
io.undertow.servlet.Servlets

public class Servlets extends Object
Utility class for building servlet deployments.
Author:
Stuart Douglas
  • Method Details

    • defaultContainer

      public static ServletContainer defaultContainer()
      Returns the default servlet container. For most embedded use cases this will be sufficient.
      Returns:
      The default servlet container
    • newContainer

      public static ServletContainer newContainer()
      Creates a new servlet container.
      Returns:
      A new servlet container
    • deployment

      public static DeploymentInfo deployment()
      Creates a new servlet deployment info structure
      Returns:
      A new deployment info structure
    • servlet

      public static ServletInfo servlet(Class<? extends javax.servlet.Servlet> servletClass)
      Creates a new servlet description with the given class. The servlet name is inferred from the simple name of the class.
      Parameters:
      servletClass - The servlet class
      Returns:
      A new servlet description
    • servlet

      public static ServletInfo servlet(String name, Class<? extends javax.servlet.Servlet> servletClass)
      Creates a new servlet description with the given name and class
      Parameters:
      name - The servlet name
      servletClass - The servlet class
      Returns:
      A new servlet description
    • servlet

      public static ServletInfo servlet(String name, Class<? extends javax.servlet.Servlet> servletClass, InstanceFactory<? extends javax.servlet.Servlet> servlet)
      Creates a new servlet description with the given name and class
      Parameters:
      name - The servlet name
      servletClass - The servlet class
      Returns:
      A new servlet description
    • filter

      public static FilterInfo filter(Class<? extends javax.servlet.Filter> filterClass)
      Creates a new filter description with the given class. The filter name is inferred from the simple name of the class.
      Parameters:
      filterClass - The filter class
      Returns:
      A new filter description
    • filter

      public static FilterInfo filter(String name, Class<? extends javax.servlet.Filter> filterClass)
      Creates a new filter description with the given name and class
      Parameters:
      name - The filter name
      filterClass - The filter class
      Returns:
      A new filter description
    • filter

      public static FilterInfo filter(String name, Class<? extends javax.servlet.Filter> filterClass, InstanceFactory<? extends javax.servlet.Filter> filter)
      Creates a new filter description with the given name and class
      Parameters:
      name - The filter name
      filterClass - The filter class
      Returns:
      A new filter description
    • multipartConfig

      public static javax.servlet.MultipartConfigElement multipartConfig(String location, long maxFileSize, long maxRequestSize, int fileSizeThreshold)
      Creates a new multipart config element
      Parameters:
      location - the directory location where files will be stored
      maxFileSize - the maximum size allowed for uploaded files
      maxRequestSize - the maximum size allowed for multipart/form-data requests
      fileSizeThreshold - the size threshold after which files will be written to disk
    • listener

      public static ListenerInfo listener(Class<? extends EventListener> listenerClass, InstanceFactory<? extends EventListener> instanceFactory)
    • listener

      public static ListenerInfo listener(Class<? extends EventListener> listenerClass)
    • securityConstraint

      public static SecurityConstraint securityConstraint()
    • webResourceCollection

      public static WebResourceCollection webResourceCollection()
    • loginConfig

      public static LoginConfig loginConfig(String realmName, String loginPage, String errorPage)
    • loginConfig

      public static LoginConfig loginConfig(String realmName)
    • loginConfig

      public static LoginConfig loginConfig(String mechanismName, String realmName, String loginPage, String errorPage)
    • loginConfig

      public static LoginConfig loginConfig(String mechanismName, String realmName)
    • errorPage

      public static ErrorPage errorPage(String location, Class<? extends Throwable> exceptionType)
      Create an ErrorPage instance for a given exception type
      Parameters:
      location - The location to redirect to
      exceptionType - The exception type
      Returns:
      The error page definition
    • errorPage

      public static ErrorPage errorPage(String location, int statusCode)
      Create an ErrorPage instance for a given response code
      Parameters:
      location - The location to redirect to
      statusCode - The status code
      Returns:
      The error page definition
    • errorPage

      public static ErrorPage errorPage(String location)
      Create an ErrorPage that corresponds to the default error page
      Parameters:
      location - The error page location
      Returns:
      The error page instance