JSP PAGE
A JSP is a normal web page with JSP
elements for generating the parts of the web
page that differ for each request.
A simple JSP web page that contains the JSP
elements and template text.
Everything on the page that is not a JSP
element is called template text.
Template text can be any text , i.e.,
HTML,XML,WML or even plain text.jsp has no
dependency on HTML ,it can be used with
any markup language.
Template text is always passed straight to the
browser
JSP ELEMENTS
There are three types of JSP elements
present:
Action
Directive
Scripting
DIRECTIVE ELEMENT
Define page-dependent attributes , such as
session tracking , error page , and buffering
requirement
Is used for importing a package.
Is used for handling an exception.
EXAMPLE:
<%@ include file=“filename” %>
<%@ include file=“header.jsp” %>
ACTION TAG/ELEMENT:
JSP acti0n tags or element are used to
perform some specific tasks.
The action tags are used to control the flow
between pages to use java beans.
There are many JSP action tags.
Jsp : forward : forward the request and
response to another resources.
Jsp : include: include another resources.
SCRIPTING ELEMENT:
Scriplet elements must be written within the
<%....%> tags.
The scriptlets tag allows writing java code
statement within the jsp page.
There are three main subdivision of scripting
elements in java server pages:
Expression tag
Scriptlets tag
Declaration tag
JSP SYNTAX:
JSP DECLARATION:
A Declaration declares one or more variable or
methods that you can use in java code later in
the jsp file.
You must declare the variable or methods before
you use it in the jsp file.
XML EQUIVALENT:
<jsp:declaration>
code fragment
</jsp:declaration>
JSP EXPRESSION:
A JSP expression element contains a scripting
language expression that is evaluated ,
converted to a string, and inserted where the
expression appears in the jsp file.
Because the value of an expression is
converted to a string, you can use an
expression within a line of text , whether print
it is tagged HTML , in a JSP file.