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
Pratik Vipul
3. All the statements which are placed within
scriptlets are moved to _ jspService() method
with Auto Generated Servlet at the time of
translation.
Syntax-
Pratik Vipul
5. Within a scriptlet following implicit objects
are made available to a JSP programmer:
* represents, is not available by default in all JSP pages.
Pratik Vipul
6. This tag is used to define data members &
methods in the Auto Generated Servlet.
Syntax-
<%!
datamember
&
method definition
%>
Pratik Vipul
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-
Pratik Vipul
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.
Pratik Vipul
11. There are 3 types of directives in JSP:
1. page directive
2. include directive
3. taglib directive
Pratik Vipul
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” %>
Pratik Vipul
14. This directive is used to include the contents
of a resource to the response of current JSP.
Syntax-
<%@ include file=”URL of Resource” %>
$Pratik Vipul
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.
Pratik Vipul
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.
Pratik Vipul
18. The <jsp:forward> action tag is used to
forward the request to another resource it
may be jsp, html or another resource.
$Pratik Vipul
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
$Pratik Vipul