2. In JSP, special tags are used to embed
dynamic content generation code into a HTML
page.
Following types of tags are used in JSP:
1. Scriptlet Tag
2. Declaration Tag
3. Expression Tag
4. Directive Tag
5. Action Tag
3.
All the statements which are placed within
scriptlets are moved to _jspService() method with
Auto Generated Servlet at the time of translation.
Syntax-
4.
5.
Within a scriptlet following implicit objects
are made available to a JSP programmer:
* represents, is not available by default in all JSP pages.
6.
This tag is used to define data members &
methods in the Auto Generated Servlet.
Syntax-
<%!
%>
datamember
&
method definition
7.
8.
This tag is used to write a String or String
returning expression to the Output Stream. In
other words, this tag provides a shorthand
mechanism of writing strings or String
returning expressions to output stream.
Example-
10.
Directives Tags are used to provide
information to the JSP translator. This
information is used by the translator at the
time of creating Servlet from the JSP.
11. There are 3 types of directives in JSP:
1. page directive
2. include directive
3. taglib directive
12.
This directive is used to provide information
such as base class for Auto Generated Servlet,
packages to be imported, content type to be
set, URL of error handler page etc.
Syntax<%@ page attribute=“value” %>
13.
14.
This directive is used to include the contents
of a resource to the response of current JSP.
Syntax<%@ include
file=”URL of Resource” %>
$
15.
taglib directive is used to specify the location of a
TLD (Tag Library Descriptor) file that defines many
tags.
Syntax<%@ taglib uri=“uniqueIdentifier/path of tld file” prefix=“prefixOfTagLibrary” %>
Example<%@ taglib uri=“http://www.rupendra.co.cc/tags” prefix=“mytag” %>
Note:
We will use this tag in custom tag section so it will
be better to learn it in custom tag.
16.
This tag is used to generate code within
_jspService() method for performing some
action such as creating an object, setting its
properties, including the contents of the
resource, forwarding the request to another
resource, etc.
The action tags basically are used to control
the flow between pages and to use java
beans.
18.
The <jsp:forward> action tag is used to
forward the request to another resource it
may be jsp, html or another resource.
$
19.
The <jsp:include> action tag is used to include
the content of another resource it may be jsp,
HTML or Servlet.
Advantage of <jsp:include> action tag:
1.
Code reusability
$