Posted On: Mar 22, 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.
Syntax
<%@ directive attribute="value" %>
The three types of directive tags are,
Example
<%@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.
Syntax
<%! declaration; %>
Example
<%! int k = 0; %>
Scriptlet tag: This tag contains the actual java code like java declaration, methods, expressions, etc.
Syntax
<% java code %>
Example
<% 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.
Syntax
<%= expression %>
Example
<%= (new java.util.Date()).toLocaleString()%>
Never Miss an Articles from us.
ErrorPage Attribute process specifies a JSP page that should process any exceptions thrown but not caught in the current page....
JSP, expanded as Java Server Pages is a Java-based technology to create dynamic web pages. Released in 1999 by Sun Microsystems, JSP is based on technologies such as HTML, SOAP, XML, etc...
The EL (Expression Language) in the JSP is used to access the data stored in the JavaBeans along with implicit objects like requests, sessions, etc...