Class ServletUtils

java.lang.Object
org.localify.common.ServletUtils

@Component public class ServletUtils extends Object
Utility class for servlet-related operations.
  • Constructor Details

    • ServletUtils

      public ServletUtils()
  • Method Details

    • setRequest

      @Autowired(required=false) public void setRequest(jakarta.servlet.http.HttpServletRequest request)
      Sets the current HTTP servlet request.
      Parameters:
      request - The request to set.
    • toInet

      public static InetAddress toInet(String ipAddr)
      Converts a string IP address to an InetAddress object.
      Parameters:
      ipAddr - The string IP address.
      Returns:
      The InetAddress object, or null if the address is invalid.
    • getRemoteAddr

      public InetAddress getRemoteAddr()
      Gets the remote address of the current request.
      Returns:
      The remote InetAddress.
      Throws:
      RuntimeException - if not in a request context.
    • addMeta

      public static void addMeta(jakarta.servlet.http.HttpServletRequest request, String key, Object value)
      Adds a key-value pair to the request's metadata map.
      Parameters:
      request - The HTTP servlet request.
      key - The key.
      value - The value.