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

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

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.



Leave a Reply 3

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


Rudi

Rudi

D is correct !

Salah Lejmi

Salah Lejmi

“web container is currently configured” –> C is correct.