Multiple choice technology web technology

Which codeline must be set before any of the lines that use the PrintWriter

  1. setContentType()

  2. setPrintType()

  3. setWriter()

  4. setContentWriter()

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

Before using PrintWriter to write response content, you must set the content type using response.setContentType() to inform the browser about the data format (e.g., text/html, application/json). This ensures proper character encoding and content rendering on the client side.