Menu

Showing posts with label JSP tags. Show all posts
Showing posts with label JSP tags. Show all posts

Java Server Pages(JSP) tags

Elements in Java server pages(JSP) are the syntax that is used to write the code in a JSP file. These elements are called tags in JSP and can be used based on requirment. JSP elements have a different component that is allowed by JSP to write or insert the Java code into the JSP file and further call the Java methods and servlets from JSP. Let's understand the purpose of a few JSP tags in this post.

JSP Declaration 

Declaration tag in JSP function as identification containers for the functions, methods and variables in JSP pages. This tag identifies Java declaration rather than generate output.

<%! jsp declaration %>

JSP Expression

Expression tag used for scripting language expression that is evaluated, converted to a String, and inserted where the expression appears in the JSP file. 

 

<%= Java statement %>

JSP Directive

Directives tag also called message tag is instructional tags that are used to provide specific instruction to web containers when the page is loaded and translated. There are three types of directive elements.

<%@ dir-type dir-attr %>

Types of directive elements
1. Page <%@ page %>
2. Include <%@ include %>
3. Taglib <%@ taglib %>

JSP Scriptlet

Scriptlet tag allows you to embed any valid Java source code in JSP server pages.
<% Java code %>

Comment Tag

The comment tag is for information only to write a message for developers and does not appear on JSP pages.
<%/ comments go here />

Flow Control Tag

Flow control tag allows us to control the order in which statements run. The conditional tags if and choose and the iterator tags forEach and forTokens are all examples of JSP flow control tags. The syntax framework for each includes <c:tag_type tag_attribute> Java code . For example, when you use an "if" statement, the correct syntax is <c: if test= "$test parameters"> Java code </c: if > where test= is the type and "$test parameters" identifies tag attributes.
<c:tag_type tag_attribute>


References

1. https://docs.oracle.com/javaee/5/tutorial/doc/bnajq.html#bnajs