Lecture Topics: Let's Start With Buzzwords. J2EE Provides
Lecture Topics: Let's Start With Buzzwords. J2EE Provides
J2EE provides:
l J2EE architecture l A component-based approach to design,
development, assembly, and deployment
l Description of the project
° Many components are reusable
l A multi-tiered distributed application model
° Means that different parts of the applications
naturally reside on different machines
l A unified security model
l A flexible transaction control
l Web services support through integrated
data interchange on XML-based open
standards and protocols
° Communication among components is standardized
CS 916, Application Security © Gleb Naumovich CS 916, Application Security © Gleb Naumovich
CS 916, Application Security © Gleb Naumovich CS 916, Application Security © Gleb Naumovich
1
J2EE containers Examples of container services
l Writing a multi-tiered distributed application from l The security model allows configuration of a
scratch is a daunting task
Web application so that only selected kinds
Lots of features have to be supported on the low-level
of users can access a specific functionality
°
! Multi-threading
! Persistence l The transaction model lets you treat a
! Transactions
! Resource pooling
number of method calls as a single
l Containers in the J2EE architecture provide this transaction
low-level support for user-defined components ° Effects of method calls can be unrolled
A container defines an interface between a component and
Naming and directory lookup services
°
the low-level platform-specific functionality that supports l
the component
! This is why components have to implement specific interfaces l Remote connectivity
l Container services are configurable ° Call methods on remote objects as if they were in
° The same application can behave differently depending on the same virtual machine
where it is deployed
CS 916, Application Security © Gleb Naumovich CS 916, Application Security © Gleb Naumovich
2
J2EE APIs, cont. J2EE APIs, cont.
l JavaMail l J2EE Connector Architecture
° For sending email notifications ° Supports creation of resource adapters
l Java API for XML Processing (JAXP) ° Used to interoperate with EISs
° XML parsing and manipulation
l Java Authentication and Authorization
° Supports DOM, SAX, XSLT Service (JAAS)
l Java API for XML Registries (JAXR) ° Allows configuration managers to creates groups
° Support for two Web registry standards of users and assign subsets of the application
l Java API for XML-Based RPC (JAX-RPC) functionality to them
° Implements XML-based remote procedure calls
l SOAP with Attachments API for Java
(SAAJ)
° Low-level API used by JAX-RPC
CS 916, Application Security © Gleb Naumovich CS 916, Application Security © Gleb Naumovich
CS 916, Application Security © Gleb Naumovich CS 916, Application Security © Gleb Naumovich
3
Servlets Servlet lifecycle
l A servlet is a Java class using the request- l Lifecycle of servlets is controlled by the servlet
container
response programming model
l When the container receives a request mapped to a
° Commonly used with the HTML protocol servlet, it
!Each request contains a URL, identifying a Web ° Checks if the servlet exists. If not, the container will:
component or a static object (HTML page, image file, ! Load the servlet class
etc.) ! Create an instance of the servlet class
!The J2EE server converts the request to an HTTP ! Call the init method of the servlet instance
request object and gives it to the servlet identified by • This method is defined by the servlet programmer and contains
the request URL any code necessary to load the initial data used by the serlvet
!The servlet fills in an HTTP response object ° Invokes a service method of the servlet, passes the request
and response objects to this method
!The J2EE server converts the HTTP response object to
an HTTP response and sends it to the client l Containers can remove servlet instances
l Application code can have listener objects that are
notified of events in servlet lifecycle
° E.g., you can log every request to a specific servlet
CS 916, Application Security © Gleb Naumovich CS 916, Application Security © Gleb Naumovich
CS 916, Application Security © Gleb Naumovich CS 916, Application Security © Gleb Naumovich
4
JavaBeans EJBs
l A JavaBean is a Java class that follows certain l Beans on steroids
design conventions
° EJB container adds a lot
l JavaBeans have properties
° A property can be read-only, write-only, or read-write
l Types of EJBs
° A property does not have to correspond to a field ° Session beans
° For each readable property, the bean must have a method ° Entity beans
of the form
PropertyClass getProperty() {…} ° Message-driven beans
° For each writable property, the bean must have a method
of the form
PropertyClass setProperty() {…}
l A JavaBean must have a constructor with no
arguments
l Special JSP tags make it convenient to use
JavaBeans with JSPs
CS 916, Application Security © Gleb Naumovich CS 916, Application Security © Gleb Naumovich
Session beans
l A session bean represents a single client
inside the J2EE server
l The client invokes the session bean’s methods
l A session bean is not shared and not
persistent
l Two types of session beans
° Stateful
!The state of the bean is preserved as its fields
° Stateless
!Although a bean may have fields, they are not used to
hold data across method invocations on this bean
!Usually, these are more efficient than stateful beans
CS 916, Application Security © Gleb Naumovich