Updated second edition, featuring new material on the Spring Framework and Maven, and new web services
Presents an accessible, easy-to-follow style
Uses powerful technologies that are freely available on the web to speed up web development
Contains numerous questions and exercises at the end of each chapter,as well as detailed illustrations, chapter summaries, and a glossary
-----------------
This comprehensive Guide to Web Development with Java introduces the readers to the three-tiered, Model-View-Controller architecture by using Spring JPA, JSPs, and Spring MVC controllers. These three technologies use Java, so that a student with a background in programming will be able to master them with ease, with the end result of being able to create web applications that use MVC, validate user input,and save data to a database.
Topics and features:
• Presents web development topics in an accessible, easy-to-follow style, focusing on core information first, and allowing the reader to gain basic understanding before moving forwards
• Contains many helpful pedagogical tools for students and lecturers, such as questions and exercises at the end of each chapter, detailed illustrations, chapter summaries, and a glossary
• Uses existing powerful technologies that are freely available on the web to speed up web development, such as Spring Boot, Spring MVC, Spring JPA, Hibernate, JSP, JSTL, and Java 1.8
• Discusses HTML, HTML forms, and Cascading Style Sheets
• Starts with the simplest technology for web development (JSP) and gradually introduces the reader to more complex topics
• Introduces core technologies from the outset, such as the Model-View-Controller architecture
• Includes examples for accessing common web services
• Provides supplementary examples and tutorials
Author(s): Tim Downey
Edition: 2
Year: 2021
Language: English
Tags: java jakarta spring mvc jsp
Preface
Contents
1 Web Applications and Maven
1.1 Hypertext Transfer Protocol
1.1.1 Request Format
1.1.2 Response Format
1.1.3 Content Type
1.2 Markup Language
1.2.1 Hypertext Markup Language
1.2.2 Basic Tags for a Web Page
1.2.3 What is the HT in HTML?
1.3 HTML Forms
1.3.1 Form Elements
1.3.2 Representing Data
1.3.3 Transmitting Data Over the Web
1.4 Web Application
1.4.1 Directory Structure
1.5 Maven
1.5.1 Maven Introduction
1.5.2 Maven Web Application
1.5.3 Maven from the Command Line
1.5.4 Maven in an IDE
1.5.5 Maven: Adding A Servlet Engine
1.6 Processing Form Data
1.6.1 JSP
1.6.2 Initialising Form Elements
1.7 The Truth About JSPs
1.7.1 Servlet for a JSP
1.7.2 Handling a JSP
1.8 Tomcat and IDEs
1.8.1 Web Project
1.9 Summary
1.10 Review
2 Controllers
2.1 Sending Data to Another Form
2.1.1 Action Attribute
2.1.2 Hidden Field Technique
2.1.3 Sending Data to Either of Two Pages
2.2 Using a Controller
2.2.1 Controller Details
2.2.2 JSP Controller
2.2.3 JSPs Versus Servlets
2.2.4 Controller Servlet
2.2.5 Servlet Access
2.2.6 Servlet Directory Structure
2.2.7 Servlet Engine for a Servlet
2.3 Maven Goals
2.3.1 Automatic Deployment
2.3.2 Debugging Servlets
2.4 Summary
2.5 Review
3 Java Beans and Member Variables
3.1 Application: Start Example
3.2 Java Bean
3.2.1 Creating a Data Bean
3.2.2 Using the Bean in a Web Application
3.3 Application: Data Bean
3.3.1 Mapping: Data Bean
3.3.2 Controller: Data Bean
3.3.3 Data Access in a View
3.3.4 Views: Data Bean
3.4 Application: Default Validation
3.4.1 Java Bean: Default Validation
3.4.2 Controller: Default Validation
3.5 Member Variables in Servlets
3.5.1 Threads
3.5.2 The Problem with Member Variables
3.5.3 Local Versus Member Variables
3.6 Application: Shared Variable Error
3.6.1 Controller: Shared Variable Error
3.7 Application: Restructured Controller
3.7.1 Creating the Helper Base
3.7.2 Creating the Controller Helper
3.7.3 Views: Restructured Controller
3.7.4 Controller: Restructured Controller
3.7.5 Restructured Controller Analysis
3.7.6 File Structure: Restructured Controller
3.8 Model, View, Controller
3.9 Summary
3.10 Review
4 Spring Framework
4.1 Spring Boot
4.1.1 Power of Interfaces
4.1.2 Injection Through Autowiring
4.2 Application: Command Line
4.2.1 Configuration
4.2.2 Command Line Arguments
4.2.3 Main Class: Command Line
4.3 Application: Spring MVC
4.3.1 Configuration
4.3.2 Servlets and Controllers
4.3.3 Static Content Locations
4.3.4 Location of the View Pages
4.3.5 Request Data Interface
4.3.6 Bean Scope
4.3.7 Singleton Controllers
4.3.8 Retrieving HTTP Variables
4.4 Application: Spring Restructured Controller
4.4.1 Modified Controller
4.5 Maven Goals
4.5.1 Testing
4.5.2 Debugging
4.6 Summary
4.7 Review
5 Spring MVC
5.1 Eliminating Hidden Fields
5.1.1 Session Structure
5.1.2 Spring Structure
5.1.3 Modifying the Controller
5.2 Controller Logic
5.2.1 Encapsulating with Methods
5.2.2 Multiple Mappings
5.3 POST Requests
5.3.1 POST Versus GET
5.3.2 Using Post
5.4 Replacing the Request
5.4.1 Adding to the Model
5.4.2 Model in a View
5.4.3 Model in a Controller
5.5 Navigation Without the Query String
5.5.1 Using Path Info
5.5.2 Default Request Mapping
5.6 Session Attributes
5.6.1 Class Annotation
5.6.2 Parameter Annotation
5.6.3 Logical Names
5.6.4 Conversational Storage
5.6.5 Usage
5.7 Logging
5.7.1 Logback
5.7.2 Configuring the Logger
5.7.3 Retrieving the Logger
5.7.4 Adding a Logger in the Bean
5.8 Application: Enhanced Controller
5.8.1 Views: Enhanced Controller
5.8.2 Model: Enhanced Controller
5.8.3 Controller: Enhanced Controller
5.9 Testing
5.10 Summary
5.11 Review
6 Validation and Persistence
6.1 Required Validation
6.1.1 Regular Expressions
6.1.2 Required Validation
6.2 Application: Required Validation
6.2.1 Views: Required Validation
6.2.2 Model: Required Validation
6.2.3 Controller: Required Validation
6.3 Additional Binders
6.3.1 Custom Editor
6.3.2 Custom Validation
6.4 Java Persistence API
6.4.1 JPA Configuration
6.4.2 Persistent Annotations
6.4.3 Accessing the Database
6.4.4 Data Persistence in Hibernate
6.5 Application: Persistent Data
6.5.1 Views: Persistent Data
6.5.2 Repository: Persistent Data
6.5.3 Controller: Persistent Data
6.6 Testing
6.7 Summary
6.8 Review
7 Advanced HTML and Form Elements
7.1 Images
7.2 HTML Design
7.2.1 In-Line and Block Tags
7.2.2 General Style Tags
7.2.3 Layout Tags
7.3 Cascading Style Sheets
7.3.1 Adding Style
7.3.2 Defining Style
7.3.3 Custom Layout with CSS
7.4 Form Elements
7.4.1 Input Elements
7.4.2 Textarea Element
7.4.3 Select Elements
7.5 Spring Form Elements
7.5.1 Spring Input Tags
7.5.2 Spring Textarea Tag
7.5.3 Spring Select Elements
7.5.4 Initialising Form Elements
7.6 Bean Implementation
7.6.1 Bean Properties
7.6.2 Filling the Bean
7.6.3 Accessing Multiple-Valued Properties
7.7 Application: Complex Elements
7.7.1 Controller: Complex Elements
7.7.2 Views: Complex Elements
7.7.3 Model: Complex Elements
7.8 Validating Multiple Choices
7.9 Application: Complex Validation
7.9.1 Model: Complex Validation
7.9.2 Views: Complex Validation
7.9.3 Controller: Complex Validation
7.10 Saving Multiple Choices
7.11 Application: Complex Persistent
7.11.1 Model: Complex Persistent
7.11.2 Views: Complex Persistent
7.11.3 Repository: Complex Persistent
7.11.4 Controller: Complex Persistent
7.12 Summary
7.13 Review
8 Accounts–Cookies–Carts
8.1 Retrieving From The Database
8.1.1 Finding a Row
8.1.2 Validating a Single Property
8.1.3 Retrieving a Record
8.2 Application: Account Login
8.2.1 Model: Account Login
8.2.2 Views: Account Login
8.2.3 Controller: Account Login
8.3 Removing Rows from the Database
8.3.1 Delete Fragment
8.3.2 Delete Repository
8.3.3 Controller: Delete Record
8.4 Application: Account Removal
8.4.1 Views: Account Removal
8.4.2 Controller: Account Removal
8.5 Account Number in Path
8.5.1 Handler Modifications for the Path
8.5.2 Model: Path Controller
8.5.3 Controller: Path Controller
8.5.4 Views: Path Controller
8.6 Cookie
8.6.1 Definition
8.6.2 Cookie Class
8.7 Application: Cookie Test
8.7.1 View: Cookie Test
8.7.2 Showing Cookies
8.7.3 Setting Cookies
8.7.4 Deleting Cookies
8.7.5 Finding Cookies
8.7.6 Path Specific Cookies
8.8 Application: Account Cookie
8.8.1 Views: Account Cookie
8.8.2 Controller: Account Cookie
8.9 Shopping Cart
8.9.1 Cart Item
8.9.2 Create Cart Item Database
8.9.3 Model: Shopping Cart
8.10 Application: Shopping Cart
8.10.1 Design Choices
8.10.2 Controller: Browse
8.10.3 Controller: Shopping Cart
8.10.4 Views: Shopping Cart
8.10.5 Shopping Cart: Enhancement
8.11 Persistent Shopping Cart
8.12 Application: Persistent Shopping Cart
8.12.1 Model: Persistent Shopping Cart
8.12.2 Views: Persistent Shopping Cart
8.12.3 Repository: Persistent Shopping Cart
8.12.4 Controller: Persistent Shopping Cart
8.13 Summary
8.14 Review
9 Web Services and Legacy Databases
9.1 Application: Google Maps
9.1.1 Model: Google Maps
9.1.2 Handler: Process Google Maps
9.1.3 Views: Google Maps
9.1.4 API Key
9.2 FedEx: Rate Service
9.2.1 Expanding the WSDL File
9.2.2 FedEx: Overview
9.2.3 Application: FedEx
9.2.4 Model: FedEx
9.2.5 Views: FedEx
9.2.6 Controller: FedEx
9.3 PayPal Web Service
9.3.1 Credentials: PayPal
9.3.2 Application: PayPal
9.3.3 Controller: PayPal
9.3.4 Views: PayPal
9.3.5 Application: PayPal with Oauth
9.4 Legacy Database
9.4.1 Eclipse Tools
9.4.2 Install the Database Driver
9.4.3 Hibernate Console
9.5 Summary
9.6 Review
10 Appendix
10.1 Spring: Object Provider
10.2 Classpath and Packages
10.2.1 Usual Suspects
10.2.2 What is a Package?
10.3 MySQL
10.3.1 Configuring MySQL
10.3.2 MySql Commands
10.4 Old School
10.4.1 Validation the Hard Way
10.4.2 Initialising Complex Elements
10.4.3 Application: Old SchoolInitialised Complex Elements
10.5 Source Code of Complicated Controllers
10.5.1 Servlet for a JSP
10.5.2 Controller Servlet
10.5.3 Restructured Controller
10.5.4 Spring Restructured Controller
10.5.5 Enhanced Controller
10.5.6 Persistent Controller
10.5.7 Complex Persistent Controller
10.5.8 Account Path and Shopping Cart
Glossary
References
Additional Resources
Books
Web Sites
Index