JAX-WS

API for XML Web Services

 

HTTP

 

 

SOAP

To provide a basic, common XML messaging protocol for the Web

 

WSDL

Establishes a common format for describing and publishing Web service

Information.

 

 

JSP

A JSP actually gets translated into a servlet by the container.

 

Three ways to pass information around:

 

Attached to:

Context

HttpSession

Request

 

Purpose of Web (servlet & JSP) Container

 

  • Communication support
  • Lifecycle management
  • Multithreading support
  • Declarative security

 

Purpose of EJB Container

 

  • Transaction Management
  • Security
  • Networking
  • Resource Management
  • Persistence
  • Concurrency
  • Messaging
  • Deploy-time customization

 

 

JSP Problems

  • Each JSP must either know how to handle all possible paths resulting from a request (for example, the path on invalid or missing parameters), resulting in complex conditionals; or must forward to another JSP as necessary, making application workflow hard to follow. It's a mistake to commit to one JSP when it's too early to predict what content we'll need to display.
  • Broken error handling. What if, halfway down the JSP, after the buffer has been flushed so it's too late to forward to another page, we encounter an exception? Although the standard JSP error page mechanism works well enough for trivial Model 1 systems, it won't help us in this plausible scenario.
  • The web interface is tied to JSP. In fact, JSP is just one view technology available to J2EE applications. JSP pages are unsuited to presenting binary data, and other technologies such as XSLT are superior at tackling some problems.
  • Java code in JSP scriptlets is hard to test and cannot be reused. Not only is this approach not object-oriented, it fails to deliver even the code reuse we would achieve in a well-written procedural application.
  • JSP pages will contain a mish-mash of markup and Java code, making them hard for either Java developers or markup experts to maintain.
  • JSP pages will bear little resemblance to the markup they generate. This defeats the point of using JSP pages, which are essentially markup components.

JSP request parameter to bean properties mapping problem

  • There is no mechanism for handling type mismatches. For example, if the value of a parameter corresponding to an int property is non-numeric, the mapping will fail silently. The int property on the bean will be left with its default value. The bean isn't capable of holding the invalid value the user supplied on any resubmission page. Without checking the request parameter directly, we can't distinguish between a missing parameter and a type mismatch.
  • The only way to establish whether a parameter was supplied is to set the default to an out-of-band value. This may not always be possible.
  • There's no mechanism for handling any exceptions thrown by the bean's property setters.
  • There's no way to specify which properties are required and which are optional.
  • We can't resolve these problems by intercepting the handling of the fields: we have no control over how the mapping is performed.

J2EE Application Servers

 

  • JBoss
  • IBM WebSphere
  • BEA WebLogic

 

EJB

 

Remote access

Local access

J2EE clients

Distributed component

 

Interfaces

EJBObject- remote interface

EJBHome- home interface

Container-managed relationship

Tightly coupled as a logical unit

 

Interfaces

EJBLocalObject- local interface

EJBLocalHome- local home interface

   

 

 

Choosing between Servlets and Stateless Session Beans

 

Servlets

Stateless Session Beans

Need to execute business logic in the same web tier

Need to handle concurrency and synchronization

Need to execute business logic within an EJB tier

Need transaction and component-level security

Need container support concurrency and synchronization

 

 

 

Remote Protocols

 

RMI

 

Oldest protocol. However, it does not provide support for authorization, encryption, compression, or HTTP tunneling.

 

Not as up-to-date as recent dynamic proxies, code-generation libraries like CGLIB, and programming techniques like AOP.

 

Session EJB

 

J2EE default protocol. Using Spring reduces the complexity. Using Spring SimpleRemoteStatelessSessionProxyFactoryBean creates a RMI proxy over the EJB object.

 

WSDL and SOAP

 

Creating WSDL

 

WSDL can be created by using package such as axis2 running on a Web Container. The client stubs can be created by using axis2 wsdl2java. axis2 admin password is stored in axis2\WEB-INF\conf

 

It can also be created by using NetBeans. Create a web service project, add to “Web Services”, and code the services using the generated code in “Source Packages”

 

 

Transactions

 

Declarative transaction demarcation

 

Specifying within the deployment descriptor the transaction attributes for the various methods of the container-managed EJB component. This is a flexible and preferable approach that facilitates changes in the application's transactional characteristics without modifying any code. Entity EJB components must use this container-managed transaction demarcation.

 

REST

 

Representational State Transfer

 

Use of HTTP to manipulate objects on server

 

  • Each unique URL represent an object, and the object can be manipulated using POST, GET, PUT, and DELETE.
  • POST = create, PUT = update