Posted On: Jan 09, 2020
Tags are an important part of JSP. There are 4 main types of JSP tags,
Directive tag: This type of tag is used to import packages into the current JSP application. The other use for this directive is to define error handling pages and for session information.
<%@ directive attribute="value" %>
The three types of directive tags are,
<%@page language="java" session="true" %> <%@ include file="/title.jsp"%>
Declaration tag: This tag is used to declare variables or methods to be used in the Java code of the JSP.
<%! declaration; %>
<%! int k = 0; %>
Scriptlet tag: This tag contains the actual java code like java declaration, methods, expressions, etc.
<% java code %>
<% out.print(“an example of scriptlet tag”); %>
Expression tag: The expression tag contains an expression that needs to be evaluated. It can contain any expression that is valid in Java code.
<%= expression %>
<%= (new java.util.Date()).toLocaleString()%>
Never Miss an Articles from us.