Java MCQ: Which directive is used to set the content type of a JSP page?
Answer:
Explanation:
The <%@ page contentType= %>
directive is used to set the content type of a JSP page. This directive specifies the MIME type of the response that the server sends to the client, which is important for defining how the client should interpret the response data.
Here’s an example of setting the content type to HTML:
<%@ page contentType="text/html;charset=UTF-8" %>
In this example, the content type is set to text/html
with a character encoding of UTF-8
, indicating that the response is an HTML document encoded in UTF-8.
Setting the correct content type ensures that the client correctly interprets the data received from the server, whether it’s HTML, JSON, XML, or another format.
Reference links:
https://www.rameshfadatare.com/learn-java-programming/
https://www.javaguides.net/p/java-tutorial-learn-java-programming.html