Docsity

Java Server Pages: Creating Dynamic Web Content with JSP, Slides of Java Programming

Partial preview of the text

Download Java Server Pages: Creating Dynamic Web Content with JSP and more Slides Java Programming in PDF only on Docsity!

Java Server Pages

^ A^ text ‐

based^ document capable

of^ returning

both

static and

dynamic content

to^ a^ client

browser.

^ Static^ content^

and^ dynamic

content

can^ be

intermixed  Static^ content– HTML,

XML,^ Text ^ Dynamic

content– Java^ code– Displaying^

properties

of^ JavaBeans

  • Invoking

business

logic^ defined

in^ Custom

tags

^ Separation

of^ dynamic and

static content

Allows^ for

the^ separation

of^ application

logic^ and

Web^ page

design.

-^ Reducing

the^ complexity of

Web^ site

development

and^ making

the^ site

easier^ to

maintain.

^ Scripting

and^ tags

-^ JSPs

support

both^ embedded JavaScript

and

tags. • JavaScript

is^ typically

used^ to

add^ page

‐ level

functionality to

the^ JSP.

-^ Tags provide

an^ easy

way^ to^ embed

and

modify^

JavaBean properties.

JSP

Architecture

Life

‐ Cycle

of^ a

JSP

Page

^ Translation

phase

^ Compile

phase ^ Execution

phase

^ JSP^ files

get^ translated

into^ servlet source

code,

which^ is

then^ compiled. ^ Done^ by

the^ container

automatically

^ The^ first

time^ JSP

page^ is^ accessed

after^ it^ is

deployed

(or^ modified

and^ redeployed) ^ For^ JSP

page^ “pageName”,

the^ source

code^ resides

  • <AppServer_HOME>/work/StandardEngine/localhost/context_root/pageName$jsp.java– <AppServer_HOME>/work/StandardEngine/localhost/date/index$jsp.java

^ Declare

methods

for^ performing

the^ following

tasks

using^ JSP

declaration

mechanism

  • Read^ persistent

configuration

data

  • Initialize

resources

  • Perform

any^ other

one‐time

activities

by

overriding

jspInit()

method^

of^ JspPage interface

^ Declare

methods

for^ performing

the^ following

tasks

using^ JSP

declaration

mechanism

  • Read^ persistent

configuration

data

  • Release

resources

  • Perform

any^ other

one‐time

cleanup^

activities

by

overriding

jspDestroy()

method^

of^ JspPage

interface

-^ Java

Server Pages are

translated

into^ a^ servlet by

the^ application

server.

-^ This

process

is^ responsible

for^ translating both

the^ dynamic

and^ static

elements

declared

within

the^ JSP^ file

into^ Java

servlet code.

-^ JSPs

are^ server

‐side^ technology,

the^ processing

of^ both^ the

static^ and

dynamic

elements

of^ the

page^ occurs

in^ the^ server.