Tags in JSP

By: aathishankaran Emailed: 1731 times Printed: 2344 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

The important syntax elements of JSP are tags.  The JSP tags do not use <%, but just the < character. 

A JSP tag is somewhat like an HTML tag.  JSP tags can have a "start tag", a "tag body" and an "end tag".  The start and end tag both use the tag name, enclosed in < and > characters.  The end starts with a / character after the < character.  The tag names have an embedded colon character : in them, the part before the colon describes the type of the tag. 

 For instance:


If the tag does not require a body, the start and end can be conveniently merged together, as


Here by closing the start tag with a /> instead of > character, we are ending the tag immediately, and without a body.  (This syntax convention is the the same as XML.)

Tags can be of two types: loaded from an external tag library, or predefined tags.   Predefined tags start with jsp: characters.  For instance, jsp:include is a predefined tag that is used to include other pages.


We have already seen the include directive in previous examples.  jsp:include is similar.  But instead of loading the text of the included file in the original file, it actually calls the included target at run-time (the way a browser would call the included target.  In practice, this is actually a simulated request rather than a full round-trip between the browser and the server). 

Following is an example of jsp:include usage


Going to include hello.jsp...<BR>
<jsp:include page="hello.jsp"/>

Try it and see what you get.  Now change the "jsp:include" to "jsp:forward" and see what is the difference.  These two predefined tags are frequently very useful.

JSP Home | All JSP Tutorials | Latest JSP Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.

Bookmark and Share


Be the first one to add a comment

Your name (required):

Your email(required, will not be shown to the public):

Your sites URL (optional):

Your comments:

More Tutorials by aathishankaran
Web Security Issues
The Web User's Perspective
Server-side plug-Ins
The best way to avoid security vulnerabilities with new server
JavaScript Security
Window Object
Working with Status Bar Messages
Retrieving a Portion of a String
Referencing Windows
Math Object
Frame Object
Document Object
Closing Windows
Built-in Object in Javascript
Textarea Object

More Tutorials in JSP
LifecycleException: service.getName(): "Catalina"; Protocol handler start failed: `java.net.BindException: Permission denied <null>:80
JSP Alert Example
JSP CheckBox Example
Uploading an Image to a Database using JSP
Uploading a file to a server using JSP
A JSP page that gets properties from a bean
The page Directive in JSP
The taglib, tag, include, attribute and the variable Directive in JSP
Declarations in JSP
Scriptlets and Expressions in JSP
Tag Libraries in JSP
The Request Object in JSP
The Response Object in JSP
The Out Object in JSP
The Session Object in JSP

More Latest News
Most Viewed Articles (in JSP )
JSP Example to connect to MS SQL database and retrieve records
JSP Alert Example
What are the different scopes in JSP?
JSP CheckBox Example
Comparison operators in JSP
JSP Program for display Date
Uploading an Image to a Database using JSP
Sending Email using JSP
Embedding java codes in jsp sciptlets
Enable/Disable Scripting Elements in JSP
The Request Object in JSP
Tags using in jsp
Automatically Refreshing a JSP
Calling JSP from a batch file
Writing your first JSP page
Most Emailed Articles (in JSP)
Techniques for form editing
Password Object
Embedding a QuickTime movie in a JSP
Scriptlets and Expressions in JSP
What is JSP?
JSP Program for display Date
Protecting your website with a login page
Sessions in JSP
Tag libraries
Tags in JSP
Basic Servlet Structure
Debugging Servlets
Select Object
The best way to avoid security vulnerabilities with new server