Tags in JSP

By: aathishankaran Emailed: 1644 times Printed: 2113 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:

<some:tag>
body
</some:tag>

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

<some:tag/>

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

 

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

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

Comments(0)


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 Program for display Date
What are the different scopes in JSP?
Sending Email using JSP
Uploading an Image to a Database using JSP
JSP Alert Example
Writing your first JSP page
JSP CheckBox Example
Example Using Initialization Parameters
Basic Servlet Structure
Arithmetic Evaluation Using the Expression Language in JSP
Enable/Disable Scripting Elements in JSP
The Request Object in JSP
Tags using in jsp
LifecycleException: service.getName(): "Catalina"; Protocol handler start failed: `java.net.BindException: Permission denied <null>:80
Most Emailed Articles (in JSP)
Tag libraries
What is JSP?
LifecycleException: service.getName(): "Catalina"; Protocol handler start failed: `java.net.BindException: Permission denied <null>:80
What is JSP?
Click to Activate and Use this control
Tags using in jsp
Introduction to JSP expression language
Disabling Scriptlets in JSP using web.xml
Cookies using JSP or Java Bean
Closing Windows
Frame Object
Retrieving a Portion of a String
Getting HTTP Request Headers in a JSP
Syntax For JSP Declaratives
JSP Program for display Date