Java MCQ: Which tag is used to write Java code in a JSP page?
Answer:
Explanation:
The <% %>
tag is used to write Java code in a JSP page. This tag, known as a scriptlet, allows you to embed Java code directly within the HTML content of the JSP file. The code within the scriptlet is executed when the JSP is processed by the server.
Here’s an example of using a scriptlet:
<% int count = 5; %>
In this example, a Java integer variable count
is declared and initialized within the JSP page using a scriptlet.
Scriptlets were commonly used in older JSP development, but in modern applications, they are often replaced by JSTL (JavaServer Pages Standard Tag Library) and EL (Expression Language) to separate Java code from HTML markup and improve maintainability.
Reference links:
https://www.rameshfadatare.com/learn-java-programming/
https://www.javaguides.net/p/java-tutorial-learn-java-programming.html