Java EE 7 Application Developer | Secure Connection for Cookie Data | Exam 1Z0-900

Secure Connection for Cookie Data

Question

How can a servlet indicate to the browser that cookie data should be sent over a secure connection?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

A.

https://docs.oracle.com/javaee/6/api/?javax/servlet/http/Cookie.html

To indicate to the browser that cookie data should be sent over a secure connection, you can call the setSecure(true) method on the cookie object.

A cookie is a small piece of data that is sent by the server to the client's browser and is stored on the client's machine. The browser then sends the cookie back to the server with every subsequent request. Cookies are often used to store user preferences or session information.

When a cookie is marked as "secure", it can only be transmitted over a secure connection, such as HTTPS. This helps to protect sensitive information that may be stored in the cookie from being intercepted by an attacker.

Option A is the correct answer because calling the setSecure(true) method on the cookie object is the standard way to indicate to the browser that the cookie should only be transmitted over a secure connection. This method sets the "secure" attribute of the cookie to true. When the browser sees this attribute, it will only send the cookie over a secure connection.

Option B is incorrect because encrypting the cookie data does not necessarily mean that the browser will automatically send the data over a secure connection. It is up to the application to ensure that the data is transmitted securely.

Option C is incorrect because there is no "ENCRYPT" header in the HTTP response. The only headers that are related to secure transmission are "Set-Cookie" and "Location" headers, and they do not have an "ENCRYPT" option.

Option D is incorrect because configuring the SessionTrackingMode.SSL on the ServletContext object only affects the session tracking mechanism and does not directly affect the transmission of cookies over a secure connection.