Package com.bobocode.bring.web.utils
Class HttpServletRequestUtils
java.lang.Object
com.bobocode.bring.web.utils.HttpServletRequestUtils
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 Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
getRequestPath
(jakarta.servlet.http.HttpServletRequest req) Retrieves the request path from the givenHttpServletRequest
, excluding the context path.static String
getShortenedPath
(String requestPath) Obtains a shortened version of the given request path, excluding the last segment (e.g., file or resource name).
-
Field Details
-
EMPTY
An empty string constant.- See Also:
-
-
Constructor Details
-
HttpServletRequestUtils
public HttpServletRequestUtils()
-
-
Method Details
-
getRequestPath
Retrieves the request path from the givenHttpServletRequest
, excluding the context path.- Parameters:
req
- The HttpServletRequest from which to extract the request path.- Returns:
- The request path without the context path.
-
getShortenedPath
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.
-