Class ContentHelper
java.lang.Object
org.deltava.taglib.ContentHelper
A Helper class to check whether content has been aded into this request. This is also used as a helper to modify the dynamic Content Security Policy.
- Since:
- 1.0
- Version:
- 12.3
- Author:
- Luke
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddContent(jakarta.servlet.jsp.PageContext ctx, String contentType, String contentName) Updates a request-located map of all inserted content files.static voidaddCSP(jakarta.servlet.jsp.PageContext ctx, ContentSecurity cs, String... hosts) Adds a host to the dynamic Content Security Policy.static voidclearContent(jakarta.servlet.ServletRequest req) Clears any included content with resetting the request, like when forwarding to an error page.static booleancontainsContent(jakarta.servlet.jsp.PageContext ctx, String contentType, String contentName) Determines if a particular content file has been inserted during this request invocation.static voidflushCSP(jakarta.servlet.jsp.PageContext ctx) Writes a dynamic Content Security Policy header to the response.static HTTPContextDatagetBrowserContext(jakarta.servlet.jsp.PageContext ctx) Fetches the browser data.static voidpushContent(jakarta.servlet.jsp.PageContext ctx, String url, String type) Adds an HTTP/2 preload link header to the response.
-
Method Details
-
addContent
public static void addContent(jakarta.servlet.jsp.PageContext ctx, String contentType, String contentName) Updates a request-located map of all inserted content files.- Parameters:
ctx- the JSP PageContextcontentType- the type of content (css/js)contentName- the name of the inserted content- See Also:
-
containsContent
public static boolean containsContent(jakarta.servlet.jsp.PageContext ctx, String contentType, String contentName) Determines if a particular content file has been inserted during this request invocation.- Parameters:
ctx- the JSP PageContextcontentType- the type of content (css/js)contentName- the name of the content- Returns:
- TRUE if the content has been added, otherwise FALSE
- See Also:
-
clearContent
public static void clearContent(jakarta.servlet.ServletRequest req) Clears any included content with resetting the request, like when forwarding to an error page. The push content list is not cleared since the headers have already been set.- Parameters:
req- the ServletRequest
-
getBrowserContext
Fetches the browser data.- Parameters:
ctx- the PageContext object- Returns:
- an HTTPContextData bean, or none if null
- See Also:
-
pushContent
-
addCSP
Adds a host to the dynamic Content Security Policy.- Parameters:
ctx- the PageContext objectcs- a ContentSecurity enumerationhosts- the host names or wildcards
-
flushCSP
public static void flushCSP(jakarta.servlet.jsp.PageContext ctx) Writes a dynamic Content Security Policy header to the response.- Parameters:
ctx- the PageContext object
-