Multiple choice technology programming languages

How do I get authentication with myServlet?

  1. HTTPRequest.setUserName()

  2. HttpServletRequest.getUserName()

  3. HTTPResponse.setUserName()

  4. HTTPResponse.getUserName()

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

In Java Servlets, user authentication information is accessed through the HttpServletRequest object using getRemoteUser() for basic authentication or getUserPrincipal() for form-based authentication. The HttpServletRequest interface provides methods to retrieve authentication data, not HTTPRequest, HTTPResponse, or setUserName methods.