Package io.jans.casa.misc
Class WebUtils
java.lang.Object
io.jans.casa.misc.WebUtils
Provides utility methods for web-related functionalities. A good place to call these methods are ZK View Models or
ZK page initiators, that is, a context where there is a ZK Execution.
- Author:
- jgomer
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidexecRedirect(String url) Performs a redirect to the url passed avoiding any UI rendering (see "Forward and redirect" in ZK developer's reference manual).static voidexecRedirect(String url, boolean voidUI) Performs a redirect to the url passed.static Stringstatic StringgetQueryParam(String param) Gets the query parameter whose name is passed as parameter.static StringGets the IP address of the originator of the current servlet request.static StringgetRequestHeader(String headerName) Gets the value of the selected header.static jakarta.servlet.http.HttpServletRequestGets the currentHttpServletRequestobject.static jakarta.servlet.http.HttpServletResponseGets the currentHttpServletResponseobject.static StringgetValueFromCookie(String cookieName) static voidinvalidateSession(jakarta.servlet.http.HttpServletRequest request) Invalidates the current http session.static StringvalidateImageUrl(String url) Reads the contents of the URL passes as param and returns null if the contents received are not image-like (e.g.
-
Field Details
-
USER_PAGE_URL
The page where users are redirected to after they have successfully logged in.- See Also:
-
ADMIN_PAGE_URL
- See Also:
-
DEFAULT_LOCALE
-
-
Method Details
-
getServletRequest
public static jakarta.servlet.http.HttpServletRequest getServletRequest()Gets the currentHttpServletRequestobject.- Returns:
- The servlet request
-
getServletResponse
public static jakarta.servlet.http.HttpServletResponse getServletResponse()Gets the currentHttpServletResponseobject.- Returns:
- The servlet response
-
getRequestHeader
Gets the value of the selected header.- Parameters:
headerName- Header name- Returns:
- Value of the header or null if the servlet request does not contain such header
-
invalidateSession
public static void invalidateSession(jakarta.servlet.http.HttpServletRequest request) Invalidates the current http session.- Parameters:
request- An HttpServletRequest instance from which the session can be obtained
-
getRemoteIP
Gets the IP address of the originator of the current servlet request.- Returns:
- A string value with the address (null if no IP could be obtained)
-
execRedirect
Performs a redirect to the url passed avoiding any UI rendering (see "Forward and redirect" in ZK developer's reference manual). It is equivalent to callingexecRedirect(url, true)- Parameters:
url- A String where the browser will be redirected to
-
execRedirect
Performs a redirect to the url passed. The boolean parameter determines if the underlying ZK execution can be voided (see "Forward and redirect" in ZK developer's reference manual).- Parameters:
url- A String where the browser will be redirected tovoidUI- Whether to void the execution
-
getQueryParam
Gets the query parameter whose name is passed as parameter.- Parameters:
param- Parameter name- Returns:
- The first value of the named parameter in the request, null if the parameter is not part of it
-
validateImageUrl
Reads the contents of the URL passes as param and returns null if the contents received are not image-like (e.g. different file format or HTTP error)- Parameters:
url- String with URL to inspect- Returns:
- The value received in parameter if it points to a valid image, null otherwise
-
getFullRequestURL
-
getValueFromCookie
-