JSP Tutorial





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
JSP Tutorial
Introduction Introduction
Installing JDK-Windows Installing JDK-Windows
Installing JDK-Linux Installing JDK-Linux
Installing Tomcat Installing Tomcat
Simple Program in JSP Simple Program in JSP
Pre-defined Variables Pre-defined Variables
Syntax of Tags Syntax of Tags
JSP Expression Language JSP Expression Language
JSP EL Operators JSP EL Operators
EL Implicit Variables EL Implicit Variables
Scopes Scopes
Using Arrays Using Arrays
Methods Methods
JSP Elements JSP Elements
Including Beans Including Beans
JSTL Tags JSTL Tags
Custom Tags Custom Tags
Session Session in JSP
Handling Cookies Handling Cookies
JSP Application Structure JSP Application Structure
Configuring web.xml Configuring web.xml
Tomcat Configuration Tomcat Configuration
JSP Examples JSP Examples
Forums Ask Your Doubts
Feedback Feedback
 






outsourced web hosting support

Syntax of Tags in JSP


Tutorials Jsp

Topic

What is the Syntax of tags in JSP?



Explanation

JSP Tags or Action Elements represent dynamic actions that occur at runtime. JSP Tags are used to write text into a file, send an email, retreive data from a database and many more. Tags are grouped into libraries called tag libraries. Tag libraries are specified in a jsp file by a uri.

Following is the syntax for tags used in JSP.

Syntax:
    <prefix:action_name attr1="value1" attr2="value2">
     action_body
    <prefix:action_name>

Following is the syntax of a JSP tag without a body.

Syntax:
    <prefix:action_name attr1="value1" attr2="value2" />

In the above syntax the closing tag is with a "/" slash at the end as it does not have a body. Usually the "prefix" attribute refers to the library the action belongs to and it enables action in different library to have the same name. The "uri" attribute identifies the tag library used for the action.

Example:
   <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
   <p>Tag Library</p>
   <c:out value="${1+2}"/>
Result:
    Tag Library
    3 

In the above example "c" is the prefix which refers the tag library "core" and "out" is the action. We use the JSTL tag c:out to display the result of adding two numbers. Here ${1+2} in an expression and is described in JSP EL.






A Note
JSP(Java Server Pages) is one of the most used Server Side Programming Language in the world. Simple introduction, basic program codes with examples. Begin coding your own JSP scripts with this online tutorial. Hope you enjoy this tutorial. Do send your feedback or suggestions on this JavaServer Pages tutorial. This is a copyright content.


Other Links

web hosting