Introduction

This book is for a large cross section of modern Java web developers, with various levels of experience.

Learning the Java programming language is a noble cause, but learning merely the Java language is not enough in the real world. Java developers have to learn Java EE, a collection of related server-side technologies, to put their Java skills to any real use.

But learning Java EE is not enough either. The Java language along with Java EE may suffice to develop web applications for projects in the same organization, as a means to reusability, but the diverse landscape of Java on the Web is permeated with several web frameworks, such as Spring Web MVC, that make development much easier; thus, a Java web developer has to have the knowledge of these web frameworks.

But this is not enough still. In the very first line of this introduction, I mentioned that this book is for a modern Java web developer. Modern Java is more than just a language; it is now a fully optimized platform because several other languages such as Groovy and Scala, called the JVM languages, now run on the Java Virtual Machine (JVM). All such JVM languages, especially Groovy, have a close association with Java, and you will come across web applications before long where Java and these other JVM languages work in tandem. The most ambitious projects will require you to build web applications using these JVM languages.

This book addresses all the needs of a modern Java web developer. It is designed for beginners up to intermediate developers and explains the specifics of Java on the Web. For example, this book is perfect for developers who are aware of technologies like MVC but do not yet understand how and why they have changed the way web applications are built.

This book is also for developers who want to learn frameworks other than JSF 2 (which is bundled with Java EE). This book covers four types of web frameworks: request based, component based, rapid, and reactive. Among these four types, the book covers five proven web frameworks: Struts 2, Spring Web MVC, JSF 2, Grails 2, and Play 2.

In addition, this book is for developers who have no experience in the Java, Groovy, and Scala programming languages but who yearn to create web applications. This book provides the essentials of these three languages in the appendixes.

Instead of simply pronouncing one web framework the best, Learn Java for Web Development shows the strengths of the most popular web frameworks by means of a real-world bookstore application. Developing a complete real application necessitates a seamless collaboration of dynamic functionalities, and the code for building such components is contrived and too involved. Instead of focusing on developing such moving parts, this book confines its attention on leveraging the strengths of each web framework.

How the Book Is Structured

The book consists of eight chapters, which I’ll describe next, plus the three previously mentioned appendixes that introduce the Java, Groovy, and Scala languages.

Chapter 1: Introducing Java Web Development

Chapter 1 explains the main objective that shapes this book and highlights what appears in the subsequent chapters. This chapter begins with a discussion of a significant change in the Java landscape, its implication, and what Java exactly means today. The chapter then discusses the three key players that join forces in building modern Java web applications: the JVM languages, Java EE, and the Java web frameworks.

This chapter introduces the key features of a modern Java web application such as Ajax and REST, WebSocket for real-time web application, the Typesafe stack for a reactive web application, and client-side MVC frameworks for responsive and single-page web applications. Finally, the chapter introduces some important aspects of modern web development that are beyond the scope of this book, such as Java information retrieval on the Web, and briefly introduces the central component of Web 3.0, which is still an open subject of research, the Semantic Web.

Chapter 2: Building Web Applications Using Servlets and JSP

Chapter 2 begins with a discussion of the evolution and architecture of web applications. The chapter then highlights how to use the standard web API. The first pass at the sample application uses only servlets and JSP. Then the chapter shows you how to build the same application as a Model 2 application.

Chapter 3: Best Practices in Java EE Web Development

Chapter 3 examines the chain of causality that leads to the need for following best practices. The chapter explains the need to evolve projects and introduces Expression Language and JSTL. The chapter then discusses the Java EE web tier patterns.

Chapter 4: Building a Web Application Using Struts 2

In Chapter 4, you’ll learn about Struts 2. Not as popular as it used to be, Struts 2 is introduced in this book for developers who have to maintain legacy applications. This chapter first introduces the key architectural components of Struts 2. Then you will learn to develop your first application using Struts 2 and Maven 4. Moving forward, you will learn to develop the bookstore application and integrate with Tiles 3.

Chapter 5: Building Java Web Applications with Spring Web MVC

Chapter 5 explains three key objectives of the Spring Framework: loose coupling using dependency injection, dealing with cross-cutting concerns using AOP, and removing boilerplate code using Spring templates. Elucidating how Spring 3 works, the chapter introduces the Spring Web MVC architecture. Then you will learn to build your first web application using Spring 3 Web MVC. This chapter also shows you how to build the bookstore application. You will learn to use the latest version of the SpringSource tool suite.

Chapter 6: Component-Based Web Development Using JSF

Chapter 6 introduces you to a component-based framework called JSF 2 that is bundled with Java EE. After you have familiarized yourself with the request-based framework presented in Chapter 4 and Chapter 5, understanding JSF 2 will be much easier. This chapter shows you how JSF 2 represents a paradigm shift in web development and introduces you to key components of the JSF 2 architecture. After you have a firm grasp of the architecture components, this chapter shows you how to develop your first JSF 2 application, and along with this you will learn the life-cycle phases of a JSF 2 application. Then the chapter shows you how to integrate JSF 2 with the Spring Framework so that you can access the database via Spring templates from the JSF 2 web layer. Finally, the chapter shows you how to develop the bookstore application.

Chapter 7: Rapid Web Development with Grails

Grails is a rapid application development framework that lets you create web applications in record time. Chapter 7 introduces you to two techniques of generating web applications with Grails: static and dynamic scaffolding. The chapter then takes you through the code generated and explains step-by-step how the code works. Having presented the code generated, this chapter shows you how to develop the bookstore application with Grails 2. This chapter also covers unit testing, an oft-neglected task in application development. This chapter shows you how to build tests for your web applications using the JUnit testing framework. Then this chapter shows you how to use the in-memory database H2. In this chapter, you will also learn to use the latest version of the Groovy-Grails tool suite.

Chapter 8: Play with Java and Scala

Chapter 8 introduces the key web player of the Typesafe stack, the Play 2 framework, and explains how the Typesafe stack provides an alternative to Java EE to build Java- and Scala-based applications. First you will learn to develop a Java-based web application using Play 2. Then you will learn to develop a Scala-based web application using Play 2. Subsequently, this chapter shows how to use the model and access a database in Play 2.

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

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