Which Java expression can be used to check whether the web container is currently configured to track sessions via URL rewriting?

Prev Question
Next Question

Which Java expression can be used to check whether the web container is currently configured to track sessions via URL rewriting?

A.
servletContext.getSessionCookiesConfiq() .isHttpOnly()

B.
servletContext.getSessionCookiesConfiq() .isSecure()

C.
servletContext.getDefaultSessionTrackingModes() .contains(SessionTrackingMode.URL)

D.
servletContext.getEffectiveSessionTrackingModes() .contains (SessionTrackingMode.URL)

Explanation:
Code example:
String sessionID = null;
if (request.getServletContext().getEffectiveSessionTrackingModes() .contains(SessionTrackingMode.URL)) {

// Get the session ID if there was one
sessionID = request.getPathParameter(
SessionConfig.getSessionUriParamName(
request.getContext()));
if (sessionID != null) {
request.setRequestedSessionId(sessionID);
request.setRequestedSessionURL(true);
}}
C: getDefaultSessionTrackingModes
java.util.Set<SessionTrackingMode> getDefaultSessionTrackingModes() Gets the session tracking modes that are supported by default for this ServletContext.

Prev Question
Next Question

Leave a Reply

Your email address will not be published. Required fields are marked *