Review Your Progress
These questions test your understanding of JEE web components and their most appropriate use to solve a given business problem:
You are the architect at a large investment bank. Your main area of responsibility is a new web application designed to replace the aging user interface for the existing clearing house back office system. One of the systems is read from/written to via a JMS Queue in asynchronous fashion and transactions and security management are paramount. Select the most appropriate implementation from the following list:
- JSP and JSTL accessing a business logic tier built using EJBs and MDBs.
- JSP and JSTL accessing a business logic tier built using MDBs only.
- JSF accessing the systems directly.
- JSP accessing the systems directly.
Answer: A. B is not flexible enough, omitting EJBs and allowing only MDBs. C and D couple the presentation tier directly to the backend resource, creating potential security, performance, and maintenance problems. A provides what is needed.
You are the architect at ACME Corporation—the hottest Internet start-up of the moment. The start-up provides a front-end accessible by multiple devices, from smart phones to desktops, and provides innovative social networking features to its members. The key considerations for the system are performance and scalability, and individual messages between members are not considered important (that is, they can be resent). Select the most appropriate implementation for this system from the following list:
- JSP + JSTL accessing the messaging layer directly.
- JSF accessing EJBs, with access to the messaging layer mediated by a JMS client and MDB.
- JSF accessing stateful session beans—one for each connected client.
- JSP + JSTL accessing a JPA-based persistence tier.
Answer: A. All of the other options contain a reasonable chance that there will be an unnecessary overhead associated with the components used—EJBs, JPA, and so on. A is the simplest answer for the business problem described, especially when the priority of performance and scalability is stated in the stem of the question.
You are a subject matter expert on JEE consulting for ACME Corporation. ACME has an existing application built using an earlier version of the JEE platform. Performance and scalability are not an issue, although system is not as maintainable as ACME would like. The application uses JSP pages as part of a Model 2 MVC architecture with Java code in the JSPs and some presentation coded as Servlets. What do you recommend?
- A complete rewrite of the existing presentation architecture to leverage JSF and JPA.
- A deeper analysis of the current system to ensure that JEE best practices (especially the MVC model) are respected throughout the code, replacing Java code in JSPs with JSTL and EL as necessary and making Servlets act purely as controllers.
- ACME move the system to use Ruby on Rails.
- A complete rewrite of the current architecture to leverage JSF, session beans, JMS, and JPA.
Answer: B. All of the other answers are nonsensical when you realize where ACME is. They have a system that works today, which requires some refactoring to move to MVC, and they simply need a roadmap after this work is completed to guide them onto JEE 6, 7, and beyond. No rewrites are necessary.
You are a JEE architect at ABC Bank and have been tasked with designing their next-generation UI framework for online banking. The online banking application must be accessible by both standard browser clients and mobile devices. What do you recommend as the simplest and most optimal solution?
- A JSF-based architecture, leveraging the capability of device or channel-specific JSF renderers to support both mobile and standard browser clients.
- A JSP-only architecture, with custom logic to probe and handle individual devices at runtime.
- A Servlet-based architecture.
- A template-based architecture.
Answer: A. JSF is designed to support exactly this type of use case—the other available options, while workable, are not the most optimal or most simple.
XYZ Corp has retained you as the architect for their latest web application: XYZOnline. This application allows customers to search, browse, and order catalog content online. XYZOnline accesses the inventory and payment systems as web services. What architecture do you recommend?
- JSP/JSF pages accessing the web services layer using stateless session beans.
- Servlets accessing the web services directly using JAX-WS as necessary.
- JSP/JSF pages accessing the web services layer using JAX-WS as necessary.
- JSP/JSF pages accessing the web services using JMS.
Answer: C. A uses stateless session beans when nothing in the description warrants their usage. B uses Servlets to generate the presentation, while D uses JMS in the wrong context. C is the best solution for the stated business requirements.
You have been asked to evaluate multiple web presentation technologies for ABC Corp. Their priorities are future-proofing, tooling support from IDEs and the ability to render multiple versions of the same component for different devices. What do you recommend to ABC?
- Use JSF components as part of a Servlet.
- Use JSTL and the EL as part of JSP pages.
- Use JSF components as part of JSP pages.
- Use JSTL and the EL as part of Servlets.
Answer: C. The key to choosing C is to realize that the question guides you there by mentioning tooling support and future proofness. B is close but does not match the requirements exactly. D and A are not valid answers.