Class ServletUtils

java.lang.Object
org.jumpmind.symmetric.web.ServletUtils

public class ServletUtils extends Object
Utility methods for working with Servlets
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    findEngine(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.ServletContext ctx)
     
    static String
    getEndpointNameFromUrl(jakarta.servlet.http.HttpServletRequest request)
     
    static String
    getEngineNameFromUrl(jakarta.servlet.http.HttpServletRequest req)
     
    static String
    getParameter(jakarta.servlet.http.HttpServletRequest request, String name)
    Returns the parameter with that name, trimmed to null
    static String
    getParameter(jakarta.servlet.http.HttpServletRequest request, String name, String defaultValue)
    Returns the parameter with that name, trimmed to null.
    static long
    getParameterAsNumber(jakarta.servlet.http.HttpServletRequest request, String name)
     
    getSymmetricEngineHolder(jakarta.servlet.ServletContext ctx)
     
    static String
    normalizeRequestUri(jakarta.servlet.http.HttpServletRequest httpRequest)
    Returns the part of the path we are interested in when doing pattern matching.
    static boolean
    sendError(jakarta.servlet.http.HttpServletResponse resp, int statusCode)
    Because you can't send an error when the response is already committed, this helps to avoid unnecessary errors in the logs.
    static boolean
    sendError(jakarta.servlet.http.HttpServletResponse resp, int statusCode, String message)
    Because you can't send an error when the response is already committed, this helps to avoid unnecessary errors in the logs.
    static boolean
    sendError(jakarta.servlet.ServletResponse resp, int statusCode)
    Because you can't send an error when the response is already committed, this helps to avoid unnecessary errors in the logs.
    static boolean
    sendError(jakarta.servlet.ServletResponse resp, int statusCode, String message)
    Because you can't send an error when the response is already committed, this helps to avoid unnecessary errors in the logs.
    static String
    whereAreYou(jakarta.servlet.http.HttpServletRequest request)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ServletUtils

      public ServletUtils()
  • Method Details

    • sendError

      public static boolean sendError(jakarta.servlet.http.HttpServletResponse resp, int statusCode) throws IOException
      Because you can't send an error when the response is already committed, this helps to avoid unnecessary errors in the logs.
      Parameters:
      resp -
      statusCode -
      Returns:
      true if the error could be sent to the response
      Throws:
      IOException
    • whereAreYou

      public static String whereAreYou(jakarta.servlet.http.HttpServletRequest request)
    • sendError

      public static boolean sendError(jakarta.servlet.http.HttpServletResponse resp, int statusCode, String message) throws IOException
      Because you can't send an error when the response is already committed, this helps to avoid unnecessary errors in the logs.
      Parameters:
      resp -
      statusCode -
      message - a message to put in the body of the response
      Returns:
      true if the error could be sent to the response
      Throws:
      IOException
    • sendError

      public static boolean sendError(jakarta.servlet.ServletResponse resp, int statusCode) throws IOException
      Because you can't send an error when the response is already committed, this helps to avoid unnecessary errors in the logs.
      Parameters:
      resp -
      statusCode -
      Returns:
      true if the error could be sent to the response
      Throws:
      IOException
    • sendError

      public static boolean sendError(jakarta.servlet.ServletResponse resp, int statusCode, String message) throws IOException
      Because you can't send an error when the response is already committed, this helps to avoid unnecessary errors in the logs.
      Parameters:
      resp -
      statusCode -
      message - a message to put in the body of the response
      Returns:
      true if the error could be sent to the response
      Throws:
      IOException
    • normalizeRequestUri

      public static String normalizeRequestUri(jakarta.servlet.http.HttpServletRequest httpRequest)
      Returns the part of the path we are interested in when doing pattern matching. This should work whether or not the servlet or filter is explicitly mapped inside of the web.xml since it always strips off the contextPath.
      Parameters:
      httpRequest -
      Returns:
    • findEngine

      public static ServerSymmetricEngine findEngine(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.ServletContext ctx)
    • getEngineNameFromUrl

      public static String getEngineNameFromUrl(jakarta.servlet.http.HttpServletRequest req)
    • getParameter

      public static String getParameter(jakarta.servlet.http.HttpServletRequest request, String name)
      Returns the parameter with that name, trimmed to null
      Parameters:
      request -
      name -
      Returns:
    • getParameter

      public static String getParameter(jakarta.servlet.http.HttpServletRequest request, String name, String defaultValue)
      Returns the parameter with that name, trimmed to null. If the trimmed string is null, defaults to the defaultValue.
      Parameters:
      request -
      name -
      Returns:
    • getParameterAsNumber

      public static long getParameterAsNumber(jakarta.servlet.http.HttpServletRequest request, String name)
    • getSymmetricEngineHolder

      public static SymmetricEngineHolder getSymmetricEngineHolder(jakarta.servlet.ServletContext ctx)
    • getEndpointNameFromUrl

      public static String getEndpointNameFromUrl(jakarta.servlet.http.HttpServletRequest request)