Package org.localify.common
Class ServletUtils
java.lang.Object
org.localify.common.ServletUtils
Utility class for servlet-related operations.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidAdds a key-value pair to the request's metadata map.Gets the remote address of the current request.voidsetRequest(jakarta.servlet.http.HttpServletRequest request) Sets the current HTTP servlet request.static InetAddressConverts a string IP address to an InetAddress object.
-
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
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
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.
-