0% found this document useful (0 votes)
138 views11 pages

JSP PDF

The document discusses Java Server Pages (JSP) which is a technology for developing dynamic web pages by embedding Java code in HTML pages. It describes the JSP lifecycle which includes compilation, initialization, execution, and cleanup. It also outlines the syntax for JSP scriptlets, declarations, expressions, comments, directives, and actions. Examples are provided of a JSP form and reading form parameters.

Uploaded by

MD NADEEM ASGAR
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
138 views11 pages

JSP PDF

The document discusses Java Server Pages (JSP) which is a technology for developing dynamic web pages by embedding Java code in HTML pages. It describes the JSP lifecycle which includes compilation, initialization, execution, and cleanup. It also outlines the syntax for JSP scriptlets, declarations, expressions, comments, directives, and actions. Examples are provided of a JSP form and reading form parameters.

Uploaded by

MD NADEEM ASGAR
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

NotesHub.co.

in | Download Android App

WEB
ENGINEERING
PPT – 5
1|Page
NotesHub.co.in | Download Android App

JSP

 JavaServer Pages (JSP) is a server-side programming technology that enables the creation of
dynamic, platform-independent method for building Web-based applications.
 JavaServer Pages (JSP) is a technology for developing web pages that support dynamic
content which helps developers insert java code in HTML pages by making use of special
JSP tags, most of which start with <% and end with %>.

JSP life Cycle


A JSP life cycle can be defined as the entire process from its creation till the destruction which is
similar to a servlet life cycle with an additional step which is required to compile a JSP into
servlet.

The following are the paths followed by a JSP

 Compilation

 Initialization

 Execution

 Cleanup

2|Page
NotesHub.co.in | Download Android App

JSP Compilation:
When a browser asks for a JSP, the JSP engine first checks to see whether it needs to compile the
page. If the page has never been compiled, or if the JSP has been modified since it was last
compiled, the JSP engine compiles the page.

The compilation process involves three steps:

 Parsing the JSP.

 Turning the JSP into a servlet.

3|Page
NotesHub.co.in | Download Android App

 Compiling the servlet.

JSP Initialization:
 When a container loads a JSP it invokes the jspInit() method before servicing any requests.

JSP Execution:
 This phase of the JSP life cycle represents all interactions with requests until the JSP is
destroyed.

 Whenever a browser requests a JSP and the page has been loaded and initialized, the JSP
engine invokes the _jspService() method in the JSP.

 The _jspService() method takes an HttpServletRequest and anHttpServletResponse

JSP Cleanup:
 The destruction phase of the JSP life cycle represents when a JSP is being removed from use
by a container.

 The jspDestroy() method is the JSP equivalent of the destroy method for servlets

4|Page
NotesHub.co.in | Download Android App

JSP Syntax

The Scriptlet:
 A scriptlet can contain any number of JAVA language statements, variable or method
declarations, or expressions that are valid in the page scripting language.

 Any text, HTML tags, or JSP elements you write must be outside the scriptlet.
Syntax: <% code %>

JSP Declarations:
 A declaration declares one or more variables or methods that you can use in Java code later
in the JSP file.

Syntax: <%! 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.

Syntax: <% =expression %>

5|Page
NotesHub.co.in | Download Android App

JSP Comments:
 JSP comment marks text or statements that the JSP container should ignore

Syntax: <%-- JSP Comment --%>


JSP Directives:
 A JSP directive affects the overall structure of the servlet class.

Syntax: <%@ directive attribute=”value”%>

6|Page
NotesHub.co.in | Download Android App

JSP Actions:
 JSP actions use constructs in XML syntax to control the behavior of the servlet engine.

Syntax: <jsp:action_name attribute=”value”>

7|Page
NotesHub.co.in | Download Android App

JSP Form Example

//Code of jsp-1.html//

//Code of NewFile1.jsp//

8|Page
NotesHub.co.in | Download Android App

Example of Reading All Form Parameters

//Code of HTML File//

9|Page
NotesHub.co.in | Download Android App

//Code of JSP File//

10 | P a g e
NotesHub.co.in | Download Android App

11 | P a g e

You might also like