JSP Action Elements - PowerPoint PPT Presentation

1 / 25
About This Presentation
Title:

JSP Action Elements

Description:

Title: No Slide Title Author: Doug Park Last modified by: zakbar Created Date: 7/1/2001 1:10:32 AM Document presentation format: On-screen Show Other titles – PowerPoint PPT presentation

Number of Views:163
Avg rating:3.0/5.0
Slides: 26
Provided by: DougP157
Category:
Tags: jsp | action | elements | java | servlet

less

Transcript and Presenter's Notes

Title: JSP Action Elements


1
JSP Action Elements
  • Lec - 37

2
JSP Journey
  • directive elements .
  • scripting elements
  • JSP comments.
  • declarations
  • expressions ....
  • scriptlets..........
  • action elements
  • special JSP tags ..

implicit objects
3
JSP Action Elements
4
JSP Action Elements
  • Format
  • Expressed using XML syntax
  • Opening tag ltjspactionElement attributevalue
    gt
  • Body body
  • Closing tag lt/jspactionElement gt
  • Empty tags without body
  • ltjspactionElement attributevalue /gt

5
JSP Action Elements cont.
  • Purpose
  • To work with JavaBeans
  • To include pages at request time
  • To forward request to another resource etc.

6
Some JSP Action Elements
  • To work with JavaBeans
  • ltjspuseBean /gt
  • ltjspsetProperty /gt
  • ltjspgetProperty /gt
  • To include resources at request time
  • ltjspinclude /gt
  • To forward request to anther JSP or Servlet
  • ltjspforward /gt
  • To work with applets
  • ltjspplugin /gt
  • And many more.

7
Working with JavaBeansusing JSP Action Elements
8
Working with JavaBeans using JSP action elements
  • JSP action elements also helps to work with
    JavaBeans
  • ltjspuseBean /gt
  • Makes a JavaBeans object available in a page
  • ltjspsetProperty /gt
  • Sets a JavaBeans property value
  • ltjspgetProperty /gt
  • Gets a JavaBeans property value

9
JSP useBean Action Element
  • jspuseBean is being equivalent to building an
    object in scriptlet
  • lt
  • MyBean m new MyBean()
  • gt
  • OR
  • ltjspuseBean id m scope page
    classvu.MyBean /gt

10
JSP setProperty Action Element
  • jspsetProperty is being equivalent to following
    code of scriptlet
  • lt
  • m.setName(ali)
  • gt
  • OR
  • ltjspsetProperty id m property name
  • valueali /gt

11
JSP getProperty Action Element
  • jspgetProperty is being equivalent to following
    code of scriptlet
  • lt
  • String name m.getName()
  • out.println(name)
  • gt
  • OR
  • ltjspgetProperty id m property name /gt

12
Sharing Beans Object Scopes
13
Understanding page Scope
first.jsp
second .jsp
third.jsp
request 1 or request 2
request 1
create
Values not available
MyBean m new MyBean()
MyBean m
m.setName(ali)
name ali
Page Context
14
Understanding request Scope
first.jsp
second .jsp
third.jsp
fourth.jsp
request 2
request 1
request 1
create
values not available
values available
MyBean m
name ali
ServletRequest
15
Understanding session Scope
first.jsp
second .jsp
third.jsp
fourth.jsp
values available
MyBean m
name ali
HttpSession
16
Understanding application Scope
first.jsp
second .jsp
third.jsp
fourth.jsp
request 2
request 1
request 1
create
values available
values available
MyBean m
name ali
ServletContext
17
Different Object Scopes
Most visible
Objects may be accessed only within pages where
they are created
page
Least visible
18
Different Object Scopes
Most visible
Only within pages processing the request in which
they are created
request
Objects may be accessed only within pages where
they are created
page
Least visible
19
Different Object Scopes
Most visible
Only from pages belonging to same session as the
one in which they were created
session
Only within pages processing the request in which
they are created
request
Objects may be accessed only within pages where
they are created
page
Least visible
20
Different Object Scopes
Within all pages belonging to same application
application
Most visible
Only from pages belonging to same session as the
one in which they were created
session
Only within pages processing the request in which
they are created
request
Objects may be accessed only within pages where
they are created
page
Least visible
21
Object Scopessession, request page
22
Object Scopessession vs. application
23
More JSP Action Elements
24
JSP include Action Element cont.
  • jspinclude is being equivalent to following code
    of scriptlet
  • lt
  • RequestDispatcher rd
    request.getRequestDispatcher(one.jsp)
  • rd.include(request, response)
  • gt
  • OR
  • ltjspinclude page one.jsp flush true /gt

25
JSP forward Action Element
  • To forward request to another resource
  • Format
  • ltjspforward pageone.jsp" /gt
  • Works similar to following code of scriptlet
  • lt
  • RequestDispatcher rd
    request.getRequestDispatcher(one.jsp)
  • rd.forward(request, response)
  • gt
Write a Comment
User Comments (0)
About PowerShow.com