Section 5: Web Tier Technologies
State the benefits and drawbacks of adopting a web framework in designing a Java EE application.
Software framework for the development of dynamic web applications. Avoids overhead in development for the web. Puts an abstract layer on top of the Servlet API.
- Automates user session management
- Automates dependency injections
- Enables use of UI templates
- Separation of design concerns (enables MVC for the web), modularization
- Supports design patterns
- Mapping requests to model operations (avoids working directly with Servlets)
- Selecting and assembling views
- Manages screen flows or navigation
- Code reuse
- Security facilities
- Learning curve
- Many popular web frameworks
- Performance overhead
- Large frameworks are in some scenarios inflexible, causes the need for workarounds
Explain standard uses for JSP pages and servlets in a typical Java EE application.
JSPs are text files that contain static formatting code (like HTML or XML) and JSP-elements (scriptlets and custom tags) that generate dynamic content.
Servlets objects work with a request-response paradigm. It is possible to output HTML code directly (not recommended).
- Servlet is created then initialized
- Zero or more service calls from clients are handle
- Servlet is destroyed then garbage collected and finalized
Model 1 Architecture
- Each JSP/Servlet handles both business logic and presentation
- Leads to poor quality (spaghetti) code
Model 2 Architecture
- Separates concerns of responsibility, splits code in MVC
- Difficult to achieve without web frameworks
Explain standard uses for JavaServer Faces components in a typical Java EE application.
- is a SUN standardized web framework
- provides a GUI framework
- enables MVC in a browser
- is event-driven
JavaServer Faces Main Components
- Java APIs to represent UI components, manage state, handle events, supports internationalization and accessibility, and validate input.
- Two JSP custom tag libraries for expressing user interface (UI) components within a JSP page (core and HTML), and for wiring components to server-side objects.
JavaServer Faces Application Components
- JavaBeans components (or model objects)
- Event listeners
- JSP pages
- Property files
- Server-side helper classes
- A custom tag library for UI components
- A custom tag library for event handlers and validators
- UI components for stateful objects on the server
- Validators, event handlers, and navigation handlers
- Configuration file (faces-config.xml)
JavaServer Faces Request Lifecycle
- Restore state of objects
- Request processed by FacesServlet
- Loads appropriate view template
- Builds component tree
- Processes events
- Renders response
- Save state of objects
Given a system requirements definition, explain and justify your rationale for choosing a web-centric or EJB-centric implementation to solve the requirements. Web-centric means that you are providing a solution that does not use EJB components. EJB-centric solution will require an application server that supports EJB components.
Web tier communicates directly with Enterprise Information Resource (EIS).
- Web interface (HTML/XML)
- Accessible from internet
- Firewall restrictions
- Public service
- Simple business logic
- EJB-container not available (Tomcat)
- Mostly read operations on objects
- Simple object model structure
- Avoid EJB performance overhead
Enterprise beans encapsulate the EIS tier and core application logic. Web tier communicates with the beans and serves only as a front end.
- Support for Fat-clients
- Security (down to method level)
- Distributed applications
- Dependency Injection
- Data integrity (transactions)
- Reuse of beans
- Support for variety of clients
- Bean lifecycle management
- Persistence management