Understanding Web Applications

The Web tier manages the interactions between Web clients and the application business logic. Typically, the Web tier generates dynamic content including HTML, XML, images, sound, video, and Java applets as responses to a client's HTTP requests. These requests can be in the form of either HTTP PUT or GET actions that are processed by the Web components to generate results back to the client. Normally, the Web container can be configured to generate and serve any content type. Business logic, on the other hand, is often implemented as EJB, which is managed by the EJB container. Web components are not transactional by design; however, they might start the transactions, which can be executed by the EJBs.

The Web tier separates application business logic from direct interaction by the client. This allows more flexibility in designing enterprise applications with different types of clients. Presentation logic is captured by Web components such as servlets, JSPs, JSP tag libraries, and JavaBeans. These Web components are deployed to and managed by the Web container.

The presentation logic is usually encapsulated into Web components that are separated from the presentation itself (that is, the contents to be displayed). The presentation logic is responsible for processing client requests, validating user input, and determining the flow of the Web pages.

In designing Web applications, the Web container can be used to maintain the user sessions, the application state, and the component's life cycle. The Web container is part of the Java 2 Enterprise Edition (J2EE) application server, therefore all common services offered by the J2EE architecture are automatically available to the Web container. Examples of such services are Java Naming and Directory Interface (JNDI), Java Database Connectivity (JDBC), Java Message Service (JMS), and JavaMail. Figure 7.1 depicts the Web container, Web components, and J2EE common services.

Figure 7.1. The Web container and Web components.


Caution

As you learned in Day 6, using stateful session beans to maintain session information is a better option in designing transactional and secure enterprise applications.


In the next few sections, you'll learn how to work with four types of Web components: servlets, JavaServer Pages, JSP tag libraries, and JavaBeans.

Note

Any of these components can access, in similar fashion, all the common services we discuss in this book. So far, we've covered JNDI on Day 4, “Using JNDI for Naming Services and Components.” JDBC will be covered on Day 9, “Using JDBC to Connect to a Database,” JMS on Day 13, “Understanding JMS and Message-Driven Beans,” and “ Implementing JavaMail in EJB Applications,” on Day 20. Above all, these Web components act as clients to the EJB components. We'll discuss some of the design consideration of accessing EJB from the Web tier when we discuss the MVC pattern later today.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.225.57.126