Class HttpServletRequestUtils

java.lang.Object
com.bobocode.bring.web.utils.HttpServletRequestUtils

public class HttpServletRequestUtils extends Object
The HttpServletRequestUtils class provides utility methods for working with HttpServletRequest. It includes methods to retrieve the request path and obtain a shortened version of the request path.
Since:
1.0
Author:
Blyzhnytsia Team
  • Field Details

  • Constructor Details

    • HttpServletRequestUtils

      public HttpServletRequestUtils()
  • Method Details

    • getRequestPath

      public static String getRequestPath(jakarta.servlet.http.HttpServletRequest req)
      Retrieves the request path from the given HttpServletRequest, excluding the context path.
      Parameters:
      req - The HttpServletRequest from which to extract the request path.
      Returns:
      The request path without the context path.
    • getShortenedPath

      public static String getShortenedPath(String requestPath)
      Obtains a shortened version of the given request path, excluding the last segment (e.g., file or resource name).
      Parameters:
      requestPath - The request path to be shortened.
      Returns:
      The shortened request path.