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.0
- Author:
- Luke
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addContent
(PageContext ctx, String contentType, String contentName) Updates a request-located map of all inserted content files.static void
addCSP
(PageContext ctx, ContentSecurity cs, String... hosts) Adds a host to the dynamic Content Security Policy.static void
Clears any included content with resetting the request, like when forwarding to an error page.static boolean
containsContent
(PageContext ctx, String contentType, String contentName) Determines if a particular content file has been inserted during this request invocation.static void
flushCSP
(PageContext ctx) Writes a dynamic Content Security Policy header to the response.static HTTPContextData
Fetches the browser data.static void
pushContent
(PageContext ctx, String url, String type) Adds an HTTP/2 preload link header to the response.
-
Method Details
-
addContent
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
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
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
Adds an HTTP/2 preload link header to the response.- Parameters:
ctx
- the PageContext objecturl
- the URL to pushtype
- the type of resource
-
addCSP
Adds a host to the dynamic Content Security Policy.- Parameters:
ctx
- the PageContext objectcs
- a ContentSecurity enumerationhosts
- the host names or wildcards
-
flushCSP
Writes a dynamic Content Security Policy header to the response.- Parameters:
ctx
- the PageContext object
-