Multiple choice technology web technology

Given that req is an HTTPServletRequest object which of the following creates a session if one does not exist ? (Choose all that apply)

  1. req.getSession()

  2. req.getSession(true)

  3. req.getSession(false)

  4. req.createSession()

  5. req.createSession(true)

  6. req.createSession(false)

Reveal answer Fill a bubble to check yourself
A,B Correct answer
Explanation

getSession() (no-arg) and getSession(true) both create a new session if one doesn't exist. getSession(false) returns null if no session exists, without creating one. The createSession() methods do not exist in the HTTPServletRequest API.