Cover image for Client-Server Web Apps with JavaScript and Java

Book description

Written specifically for Java developers, this book describes and demonstrates the creation of JavaScript rich web applications that communicate with RESTful JSON web services implemented in Java. This development approach maintains a clear distinction between client-side and server-side technologies, in contrast to JSF, GWT, and similar server-side templating technologies where user-interface development is largely performed server side.

Table of Contents

  1. Preface
    1. Who Is This Book For?
    2. How This Book Is Organized
    3. Conventions Used in This Book
    4. Code Examples
      1. Long Command Formats
    5. Safari® Books Online
    6. How to Contact Us
    7. Acknowledgments
  2. 1. Change Begets Change
    1. Web Users
    2. Technology
    3. Software Development
    4. What Has Not Changed
      1. The Nature of the Web
      2. Server-Driven Web Development Considered Harmful
    5. Why Client-Server Web Applications?
      1. Code Organization/Software Architecture
      2. Flexibility of Design/Use of Open Source APIs
      3. Prototyping
      4. Developer Productivity
      5. Application Performance
    6. Conclusion
  3. 2. JavaScript and JavaScript Tools
    1. Learning JavaScript
    2. JavaScript History
    3. A Functional Language
      1. Scope
      2. First-Class Functions
      3. Function Declarations and Expressions
      4. Function Invocations
      5. Function Arguments
      6. Objects
    4. JavaScript for Java Developers
      1. HelloWorld.java
        1. Program execution
        2. File system organization
      2. HelloWorld.java (with Variables)
    5. Development Best Practices
      1. Coding Style and Conventions
      2. Browsers for Development
      3. Integrated Development Environments
      4. Unit Testing
      5. Documentation
    6. Project
  4. 3. REST and JSON
    1. What Is REST?
      1. Resources
      2. Verbs (HTTP Request Methods)
      3. Uniform Resource Identifiers
    2. REST Constraints
      1. Client–Server
      2. Stateless
      3. Cacheable
      4. Uniform Interface
      5. Layered
      6. Code on Demand
    3. HTTP Response Codes
      1. What Is Success?
    4. JSON (JavaScript Object Notation)
    5. HATEOAS
      1. REST and JSON
    6. API Measures and Classification
    7. Functional Programming and REST
    8. Project
    9. Other Web API Tools
    10. Constraints Redux
  5. 4. Java Tools
    1. Java Language
    2. Java Virtual Machine (JVM)
    3. Java Tools
    4. Build Tools
      1. Benefits of Maven
      2. Functionality of Maven
      3. Version Control
      4. Unit Testing
    5. JSON Java Libraries
    6. Projects
      1. Java with JSON
      2. JVM Scripting Languages with JSON
    7. Conclusion
  6. 5. Client-Side Frameworks
    1. Overview
    2. Starting Point One: Responsive Web Design
      1. HTML5 Boilerplate
      2. Bootstrap
    3. Starting Point Two: JavaScript Libraries and Frameworks
      1. Browser Compatibility
      2. Frameworks
      3. Functionality
      4. Popularity
    4. Obtaining Starter Projects
      1. Download Directly from Repositories
      2. Download from Starter Sites
      3. IDE-Generated Starter Projects
    5. The Rise of the Front-End Engineer
      1. Client-Side Templating
      2. Asset Pipelines
      3. Development Workflow
    6. Project
    7. Conclusion
  7. 6. Java Web API Servers
    1. Simpler Server-Side Solutions
    2. Java-Based Servers
      1. Java HTTP Server
      2. Embedded Jetty Server
      3. Restlet
      4. Roo
      5. Embedded Netty Server
      6. Play Server
      7. Other Lightweight Server Solutions
    3. JVM-Based Servers
      1. Jython
    4. Web Application Servers
    5. Development Usage
    6. Conclusion
  8. 7. Rapid Development Practices
    1. Developer Productivity
    2. Optimizing Developer and Team Workflow
      1. Example: Web Application Fix
      2. Example: Testing Integration
      3. Example: Greenfield Development
    3. Productivity and the Software Development Life Cycle
      1. Management and Culture
      2. Technical Architecture
      3. Software Tools
      4. Performance
      5. Testing
      6. Underlying Platform(s)
    4. Conclusion
  9. 8. API Design
    1. A Decision to Design
    2. Practical Web APIs Versus RESTful APIs
    3. Guidelines
      1. Nouns as Resources; Verbs as HTTP Actions
      2. Query Parameters as Modifiers
      3. Web API Versions
      4. HTTP Headers
      5. Linking
      6. Responses
      7. Documentation
      8. Formatting Conventions
      9. Security
    4. Project
      1. Running the Project
      2. Server Code
      3. Curl and jQuery
    5. Theory in Practice
  10. 9. jQuery and Jython
    1. Server Side: Jython
      1. Python Web Server
      2. Jython Web Server
      3. Mock APIs
    2. Client Side: jQuery
      1. DOM Traversal and Manipulation
      2. Utility Functions
      3. Effects
      4. Event Handling
      5. Ajax
    3. jQuery and Higher-Level Abstractions
    4. Project
      1. Basic HTML
      2. JavaScript and jQuery
    5. Conclusion
  11. 10. JRuby and Angular
    1. Server Side: JRuby and Sinatra
      1. Workflow
      2. Interactive Ruby Shell
      3. Ruby Version Manager (RVM)
      4. Packages
      5. Sinatra
      6. JSON Processing
    2. Client Side: AngularJS
      1. Model
      2. Views
      3. Controllers
      4. Services
    3. Comparing jQuery and Angular
      1. DOM Versus Model Manipulation
      2. Unobtrusiveness of Angular
    4. Project
    5. Conclusion
  12. 11. Packaging and Deployment
    1. Java and JEE Packaging
    2. JEE Deployment
      1. GUI Administration
      2. Command-Line Administration
    3. Non-JEE Deployment
      1. Server Outside
      2. Server Alongside
      3. Server Inside
    4. Implications of Deployment Choice
      1. Load Balancing
      2. Automating Application Deployment
    5. Project
      1. Client
      2. Server
    6. Conclusion
  13. 12. Virtualization
    1. Full Virtualization
    2. Virtual Machine Implementations
      1. VMWare
      2. VirtualBox
      3. Amazon EC2
    3. Management of Virtual Machines
      1. Vagrant
      2. Packer
      3. DevOps Configuration Management
    4. Containers
      1. LXC
      2. Docker
    5. Project
      1. Docker Help
      2. Image and Container Maintenance
      3. Java on Docker
      4. Docker and Vagrant Networking
    6. Conclusion
  14. 13. Testing and Documentation
    1. Types of Testing
      1. Formal Versus Informal
      2. Extent of Testing
      3. Who Tests What for Whom?
    2. Testing as an Indicator of Organizational Maturity
      1. CMM to Assess Process Uniformity
      2. Maven to Promote Uniform Processes
      3. BDD to Promote Uniform Processes
    3. Testing Frameworks
      1. JUnit
      2. Jasmine
      3. Cucumber
    4. Project
      1. JUnit
      2. Jasmine
      3. Cucumber
      4. Maven Site Reports
    5. Conclusion
  15. 14. Conclusion
    1. Community
    2. History
    3. Coda
  16. A. JRuby IRB and Java API
    1. Setup Using Gradle
    2. JRuby IRB
      1. Intro to IRB
    3. Java-Based Relational Databases
      1. H2
      2. HSQLDB
      3. Derby
    4. Conclusion
  17. B. RESTful Web API Summary
    1. HTTP 1.1 Request Methods
    2. HTTP 1.1 Response Codes
    3. Curl for Web APIs
    4. JSON Syntax
      1. JSON Types
    5. Railroad Diagrams
      1. Object
      2. Array
      3. Value
  18. C. References
  19. Index
  20. Colophon
  21. Copyright