Java MCQ: What is the purpose of the <%= %> tag in JSP?
a) To declare a variable
b) To include a file
c) To output the result of an expression
d) To create a comment
Answer:
c) To output the result of an expression
Explanation:
The <%= %>
tag in JSP is used to output the result of an expression directly to the client’s browser. This tag, known as an expression tag, evaluates the expression and converts the result to a string, which is then inserted into the HTML output.
Here’s an example of using an expression tag:
<h1>The count is: <%= count %></h1>
In this example, the value of the count
variable is output within the HTML content of the JSP page using an expression tag.
Expression tags are useful for embedding dynamic content in JSP pages, such as displaying variable values, without requiring additional scriptlet code.
Reference links:
https://www.rameshfadatare.com/learn-java-programming/
https://www.javaguides.net/p/java-tutorial-learn-java-programming.html