100% found this document useful (1 vote)
17 views

Learn Java for Web Development Modern Java Web Development 1st Edition Vishal Layka - The ebook is ready for instant download and access

The document promotes the book 'Learn Java for Web Development' by Vishal Layka, which covers essential Java web development concepts and frameworks for both beginners and intermediate developers. It includes chapters on various web frameworks such as Struts 2, Spring Web MVC, and JSF 2, as well as appendices introducing Java, Groovy, and Scala. The document also provides links to download the book and other related resources from ebookfinal.com.

Uploaded by

maneynosmas
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
17 views

Learn Java for Web Development Modern Java Web Development 1st Edition Vishal Layka - The ebook is ready for instant download and access

The document promotes the book 'Learn Java for Web Development' by Vishal Layka, which covers essential Java web development concepts and frameworks for both beginners and intermediate developers. It includes chapters on various web frameworks such as Struts 2, Spring Web MVC, and JSF 2, as well as appendices introducing Java, Groovy, and Scala. The document also provides links to download the book and other related resources from ebookfinal.com.

Uploaded by

maneynosmas
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 57

Visit ebookfinal.

com to download the full version and


explore more ebooks or textbooks

Learn Java for Web Development Modern Java Web


Development 1st Edition Vishal Layka

_____ Click the link below to download _____


https://ebookfinal.com/download/learn-java-for-web-
development-modern-java-web-development-1st-edition-vishal-
layka/

Explore and download more ebooks or textbook at ebookfinal.com


Here are some recommended products that we believe you will be
interested in. You can click the link to download.

Learn Java Fundamentals A Primer for Java Development and


Programming 1st Edition Jeff Friesen

https://ebookfinal.com/download/learn-java-fundamentals-a-primer-for-
java-development-and-programming-1st-edition-jeff-friesen/

Beginning JSP JSF and Tomcat Java Web Development 2nd


Edition Giulio Zambon

https://ebookfinal.com/download/beginning-jsp-jsf-and-tomcat-java-web-
development-2nd-edition-giulio-zambon/

Java Web Services 1st ed Edition David A. Chappell

https://ebookfinal.com/download/java-web-services-1st-ed-edition-
david-a-chappell/

Java Web Services Up and Running 1st Edition Martin Kalin

https://ebookfinal.com/download/java-web-services-up-and-running-1st-
edition-martin-kalin/
The Modern Web Multi Device Web Development with HTML5
CSS3 and JavaScript 1st New edition Edition Peter Gasston

https://ebookfinal.com/download/the-modern-web-multi-device-web-
development-with-html5-css3-and-javascript-1st-new-edition-edition-
peter-gasston/

Flask Web Development 1st Edition Miguel Grinberg

https://ebookfinal.com/download/flask-web-development-1st-edition-
miguel-grinberg/

ArcGIS Web Development 1st Edition Rene Rubalcava

https://ebookfinal.com/download/arcgis-web-development-1st-edition-
rene-rubalcava/

Flask Web Development Developing Web Applications with


Python 1st Edition Miguel Grinberg

https://ebookfinal.com/download/flask-web-development-developing-web-
applications-with-python-1st-edition-miguel-grinberg/

Java EE Development with Eclipse 2nd Edition Ram Kulkarni

https://ebookfinal.com/download/java-ee-development-with-eclipse-2nd-
edition-ram-kulkarni/
Learn Java for Web Development Modern Java Web
Development 1st Edition Vishal Layka Digital Instant
Download
Author(s): Vishal Layka
ISBN(s): 9781430259831, 1430259833
Edition: 1
File Details: PDF, 16.88 MB
Year: 2014
Language: english
For your convenience Apress has placed some of the front
matter material after the index. Please use the Bookmarks
and Contents at a Glance links to access them.
Contents at a Glance
About the Author���������������������������������������������������������������������������������������������������������������� xv
About the Technical Reviewer������������������������������������������������������������������������������������������ xvii
Introduction����������������������������������������������������������������������������������������������������������������������� xix

■■Chapter 1: Introducing Java Web Development����������������������������������������������������������������1


■■Chapter 2: Building Web Applications Using Servlets and JSP���������������������������������������43
■■Chapter 3: Best Practices in Java EE Web Development�����������������������������������������������105
■■Chapter 4: Building a Web Application Using Struts 2��������������������������������������������������161
■■Chapter 5: Building Java Web Applications with Spring Web MVC�������������������������������203
■■Chapter 6: Component-Based Web Development Using JSF 2��������������������������������������263
■■Chapter 7: Rapid Web Development with Grails������������������������������������������������������������299
■■Chapter 8: Play with Java and Scala�����������������������������������������������������������������������������355
■■Appendix A: Introduction to Java����������������������������������������������������������������������������������383
■■Appendix B: Introduction to Groovy�������������������������������������������������������������������������������399
■■Appendix C: Introduction to Scala���������������������������������������������������������������������������������423

Index���������������������������������������������������������������������������������������������������������������������������������435

v
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.

xix
xx Introduction

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.
Introduction xxi

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.
Chapter 1
Introducing Java Web
Development
The mind, once stretched by a new idea, never returns to its original dimensions.

—Ralph Waldo Emerson

An intelligent machine is that which extends the very imagination with which it was built. An example
of this is the instruction called invokeDynamic,1 which was introduced with Java 7 to optimize the
performance of dynamically typed languages on the Java Virtual Machine (JVM). The JVM, originally
intended for Java, can now host a myriad of programming languages, including Groovy2 and Scala.3
This has led to a renaissance of Java web development. This new paradigm of cross-pollination and
diverse, well-founded options carves out a number of niches in the Java ecosystem, resulting in a
richer web landscape than ever before.
The open source community has capitalized on the multiparadigm capabilities offered by the
languages that run on the JVM, by means of web frameworks, to dramatically enhance the
productivity in web development. Java EE4 advanced this momentum, pioneered by Java
frameworks such as Spring,5 by standardizing and improving the API and runtime environment.
Further, functional programming constructs, in the form of lambdas, have been added to Java 8. As
a result, Java is on the rebound to become an übersolution.
This chapter sets the stage for the book by introducing the three key players that join forces in
building modern Java web applications: the JVM languages, Java EE, and the Java web frameworks.

1
http://cr.openjdk.java.net/~jrose/pres/200910-VMIL.pdf
2
http://groovy.codehaus.org/
3
www.scala-lang.org/
4
www.oracle.com/technetwork/java/javaee/overview/index.html
5
http://spring.io/

1
2 CHAPTER 1: Introducing Java Web Development

Note The JVM languages represent a new category of languages that run on the JVM. With the latest
version, Java 8, Java is no longer a privileged JVM language and is now simply one of the many languages
that run on the JVM.

The chapter begins by introducing the JVM languages and then introduces Java EE. The Java
EE platform is the set of API specifications that act as the building blocks for developing web
applications. The chapter then highlights the Java web frameworks, which will be the subject of the
book from Chapter 4 onward.

JVM Languages
The JVM is the runtime environment that provides you with the ability to use different programming
languages for building web applications. The JVM languages can be largely classified into two types:
languages that are designed for the JVM and existing languages that are ported to JVM.

Languages Designed for the JVM


Plenty of languages are specifically designed for the JVM; Table 1-1 describes a few of them. All but
Clojure are discussed in this book.

Table 1-1. Languages Designed for the JVM


Language Designed for JVM Description
Clojure6 Clojure is a dynamically typed, functional language.
Groovy Groovy is a dynamic, compiled language with syntax similar to Java but is
more flexible.
Java Java is a statically typed, imperative language. The latest release of Java,
Java 8, supports aspects of functional programming.
Scala Scala is a statically typed, compiled language that supports aspects of
functional programming and performs a large amount of type inference,
much like a dynamic language.

Here are some important definitions:


 Dynamic typing: Dynamic typing keeps track of information about what sort of
values the variables contain by carrying the type information on the values held
in variables.
 Static typing: In static typing, the type information is all about the variables, not
the values in them.

6
http://clojure.org/
CHAPTER 1: Introducing Java Web Development 3

 Imperative languages: These are languages in which the state can be mutated
by the instructions in the language.
 Functional languages: In functional languages, the functions operate on values
as in procedural languages, but instead of mutating the state, the functions are
purely mathematical functions that return new values.
Figure 1-1 shows where Java 8, Groovy, Scala, and Clojure fall on the functional language
continuum. Java 8 introduces lambdas, which makes it slightly functional, Groovy has had functional
constructs since its inception and is even more functional with Groovy 2.0, and Scala is the most
functional of the three object-oriented (OO) languages. Clojure, on the other hand, is a purely
functional, non-OO language.

Figure 1-1. Functional gradation of JVM languages

Note In Figure 1-1, no version number is mentioned for Groovy, Scala, and Clojure because Java supports
aspects of functional programming starting from Java 8 only.

Languages Ported to the JVM


JRuby, Jython, and Rhino are a few of the mainstream JVM implementations of existing languages.
Table 1-2 describes them.
4 CHAPTER 1: Introducing Java Web Development

Table 1-2. Languages Ported to the JVM


Languages Ported to JVM Description
JRuby7 JRuby is a JVM reimplementation of the Ruby programming language. Ruby is a
dynamically typed OO language with some functional features.
Jython8 Jython is a reimplementation of Python on the JVM, so it is a dynamic language.
Rhino 9
Rhino provides an implementation of JavaScript on the JVM. JavaScript is a
dynamically typed OO language.

This book is based on some of the mainstream object-oriented JVM languages that were specifically
designed for the JVM, namely, Java, Groovy, and Scala.

Java EE
Java began life as a programming language designed for building stand-alone applications and grew
rapidly into other spheres. A large part of Java’s popularity can be attributed to its usage in creating
web applications. A web application consists of static and dynamic (interactive) web pages. Static
web pages contain various types of markup languages (HTML, XHTML, and so on) and are used, in
general, to provide information; dynamic web pages, on the other hand, are capable of generating
content with the aid of additional web components (covered in Chapter 2). Thus, a web application
is a collection of web pages and is capable of generating dynamic content in response to requests.
Unlike a web page used merely to provide information, a web application lets you perform some
activity and save the result. Developing a web application, however, is fundamentally different from
building stand-alone applications and requires you to understand the following three key elements:
 The Java EE platform: This is the set of API specifications that are the building
blocks of the web application.
 The web container: The web container implements the API specifications of
the Java EE platform. Specifically, the web container provides the services
for managing and executing web components such as servlets, JSPs, filters,
listeners, and render responses to the client. The web containers are covered in
Chapter 2.

Note There are several types of containers, but this book will focus on the web container primarily used for
web applications. You have to choose the container based on the kind of application you want to develop.

 Web components: These are hosted by the container. These web components,
such as servlets, JSPs, filters, and listeners, are covered in Chapter 2.

7
http://jruby.org/
8
www.jython.org/
9
https://developer.mozilla.org/en-US/docs/Rhino_documentation
CHAPTER 1: Introducing Java Web Development 5

The Java EE Platform


The Java EE platform is driven by the following two goals:
 Providing the API specifications that are the building blocks of the web
application.
 Standardizing and reducing the complexity of enterprise application
development. It does this by providing an application model that defines an
architecture for implementing services as multitiered applications.
Figure 1-2 summarizes the evolution of Java EE and, for the sake of brevity, shows only the new
specifications added with each release.

Figure 1-2. The evolution of Java EE

Note Pruning (also known as marked for deletion) consists of a list of proposed features for possible
removal in the next Java EE release in order to reduce the size of the platform or to keep it from bloating.

The goal of Web Profile is to allow developers to create web applications with the appropriate set of
technologies.

The Java EE platform is aimed at standardizing and reducing the complexity of enterprise application
development by providing an application model that defines an architecture for implementing
services as multitiered applications. In a multitiered application, the functionality of the application
is separated into distinct functional areas, called tiers. Figure 1-3 illustrates the typical multitiered
architecture in a Java EE application model.
6 CHAPTER 1: Introducing Java Web Development

Figure 1-3. Multitier architecture in Java

The Client Tier


The client tier is the top tier in a multitiered Java EE architecture; it consists of application clients
that make requests to the Java EE server, which is often located on a different machine. The server
processes the requests and returns a response to the client. An example of a client is a web browser
or a stand-alone application.

The Web Tier


The web tier consists of components that handle the interaction between clients and the business
tier. After receiving a request from the client, the web tier does the following:
1. Collects input from the client
2. Controls the flow of screens or pages on the client
3. Maintains the state of data for a user’s session
4. Obtains results from the components in the business tier
5. Generates dynamic content in various formats to the client
As shown in Figure 1-2, a new Web Profile specification has been added in Java EE 7.10 Table 1-3
lists technologies included in the Web Profile specification. As mentioned earlier, the goal of Web
Profile is to allow developers to create web applications with the appropriate set of technologies.

10
www.oracle.com/technetwork/java/javaee/tech/index.html
CHAPTER 1: Introducing Java Web Development 7

Table 1-3. Web Profile 7 Specification


Specification Version URL
JSF 2.2 http://jcp.org/en/jsr/detail?id=344
JSP 2.3 http://jcp.org/en/jsr/detail?id=245
JSTL 1.2 http://jcp.org/en/jsr/detail?id=52
Servlet 3.1 http://jcp.org/en/jsr/detail?id=340
WebSocket 1.0 http://jcp.org/en/jsr/detail?id=356
Expression Language 3.0 http://jcp.org/en/jsr/detail?id=341
EJB Lite 3.2 http://jcp.org/en/jsr/detail?id=345
JPA 2.1 http://jcp.org/en/jsr/detail?id=338
JTA 1.2 http://jcp.org/en/jsr/detail?id=907
Bean Validation 1.1 http://jcp.org/en/jsr/detail?id=349
Managed Beans 1.0 http://jcp.org/en/jsr/detail?id=316
Interceptors 1.2 http://jcp.org/en/jsr/detail?id=318
Contexts and Dependency 1.1 http://jcp.org/en/jsr/detail?id=346
Injection
Dependency Injection for Java 1.0 http://jcp.org/en/jsr/detail?id=330
Debugging Support for Other 1.0 http://jcp.org/en/jsr/detail?id=45
Languages
JAX-RS 2.0 http://jcp.org/en/jsr/detail?id=339
JSON-P 1.0 http://jcp.org/en/jsr/detail?id=353

Regarding the Web Profile specifications listed in Table 1-3:


 In Java EE 7, no changes were made to JSP and JSTL because these
specifications have not been updated.
 Expression Language has been removed from JSP and now has its own
JSR (341).
 Servlets and JSF have both been updated.
 WebSocket 1.0 was introduced in Java EE 7.
This book concentrates on the web tier of Java EE; we will dive deep into the web tier in Chapter 2.
The multitier architecture of Java EE has a tremendous impact on the development of Java
enterprise applications. A Java enterprise application can be defined as a Java application that
utilizes the enterprise services offered by Java EE. In fact, a web application can be classified as
an enterprise application if it utilizes Java EE services in the form of components packed in the
web tier. Java EE isolates these services functionally into separate tiers, as illustrated in Figure 1-3,
by providing an application model on which the Java enterprise applications should be built. As a
consequence, the Java enterprise application mirrors the multitier architecture of Java EE. Figure 1-4
illustrates a generalized view of the layers of a typical web application.
8 CHAPTER 1: Introducing Java Web Development

Figure 1-4. A generalized view of layers in an enterprise application

Each layer in Figure 1-4 is an area of concern, for the application. For instance, the web layer deals
only with employing the web tier components of Java EE. Having different layers in an application
results in what is called a separation of concerns. In terms of implementation, this separation of
concerns is achieved using coarse-grained interfaces.
The concern is the feature, functionality or business functions with which the application’s
developer needs to be concerned. Crosscutting such concerns is inherent in complex systems
and leads to code scattering, which is when code for one concern spans many modules, and
code tangling, which is when code in one module concentrates on addressing multiple concerns.
Code scattering and code tangling lead to a lack of clarity, redundancy, rigidity, and continuous
refactoring. Figure 1-5 illustrates how the system services of logging, transaction, and security
crosscut the business functions of the application.

Figure 1-5. BookService involved with system services

BookService in Figure 1-5 is too involved with the system services. Each object knows and is
responsible for logging, security, and transaction. A method, for example, to purchase a book in
BookService should be concerned only with how to purchase the book and not with whether it is
CHAPTER 1: Introducing Java Web Development 9

secure or transactional. Separation of concerns, one of the main goals of software engineering, lets
you handle each service on its own and thereby does the following:
 Promotes traceability within and across the artifacts in the system, throughout
the life cycle of the system
 Controls the impact caused by the change, thereby providing scope for
evolution and noninvasive adaptation
 Promotes development of cohesive units, thereby facilitating reuse

SEPARATION OF CONCERNS

The term separation of concerns (SoC) was coined by Edsger W. Dijkstra in his paper “On the role of scientific thought.”11
Dijkstra explains in in the following terms:

Let me try to explain to you, what to my taste is characteristic for all intelligent thinking. It is, that
one is willing to study in depth an aspect of one’s subject matter in isolation for the sake of its own
consistency, all the time knowing that one is occupying oneself only with one of the aspects. We
know that a program must be correct and we can study it from that viewpoint only; we also know
that it should be efficient and we can study its efficiency on another day, so to speak. In another mood
we may ask ourselves whether, and if so: why, the program is desirable. But nothing is gained—on
the contrary!—by tackling these various aspects simultaneously. It is what I sometimes have called
“the separation of concerns,” which, even if not perfectly possible, is yet the only available technique
for effective ordering of one’s thoughts, that I know of. This is what I mean by “focusing one’s attention
upon some aspect”: it does not mean ignoring the other aspects, it is just doing justice to the fact
that from this aspect’s point of view, the other is irrelevant. It is being one- and multiple-track minded
simultaneously.

Web Layer
The web layer of a web application consists of the web tier components of Java EE such as servlets
and JSP. The web layer can access the service layer, but there should not be a tight coupling
between the web layer and the service layer. That is, changing the service layer should not impact
the web layer.

11
www.cs.utexas.edu/users/EWD/transcriptions/EWD04xx/EWD447.html
10 CHAPTER 1: Introducing Java Web Development

Service Layer
The service layer consists of the business tier components of Java EE such as Enterprise JavaBeans
(EJBs). The service layer can access the data access layer, but there should be no tight coupling
between the service layer and the data access layer. In fact, the service layer should not know
anything about the web or data access layer. The service layer provides a coarse-grained interface
for the web layer.

Data Access Layer


The data access layer consists of the data tier components of Java EE such as JDBC and JPA. This
layer should not contain any business logic. This layer abstracts the actual persistence mechanism
(in other words, JDBC or JPA) from the service layer by providing the coarse-grained interface to the
service layer.

Note The call flow in this architecture is always from the top layer to the bottom layer. In other words, the
service layer should be able to call the data access layer but not vice versa.

In this chapter, you will build the data access layer of the bookstore application and query it via a
stand-alone Java application. In Chapter 2, you will replace this stand-alone Java application with
a web layer using the web tier components of Java EE (specifically, servlets and JSPs). You will
use this data access layer throughout this book, and from Chapter 4 onward you will build a web
application repeatedly by rebuilding the web layer using different web frameworks.
Oracle and the Java Community Process (JCP) provide standardized enterprise components, and if
successful enterprise applications can be built using these components, then why do we need web
frameworks? What are web frameworks for? The next section answers these questions.

Java Web Frameworks


While Java EE does a great job of standardizing the enterprise infrastructure, providing an
application model, and providing components adequate to develop web applications, two major
problems are associated with it.
 Interacting directly with the Java EE components often results in massive
boilerplate code and even code redundancy.
 Creating an enterprise application using the Java EE infrastructure is a nontrivial
task that requires a great deal of expertise. The team members usually involved
in creating an enterprise Java EE application act in varied roles, and all of them
may not have the level of expertise that meets the Java EE criteria.
Frameworks address these two major problems (and several other concerns discussed in detail in
Chapter 3). Table 1-4 describes the web frameworks you will learn about in this book.
CHAPTER 1: Introducing Java Web Development 11

Table 1-4. JVM-Based Web Frameworks


Web Frameworks Language Download From
Struts 2 Java http://struts.apache.org/download.cgi#struts2314
Spring Web MVC Java www.springsource.org/spring-community-download
JSF 2 Java www.oracle.com/technetwork/java/javaee/downloads/index.html
Grails 2 Groovy www.grails.org/download
Play 2 Java and Scala www.playframework.com/download

Now that you have looked at the three key players that join forces in building modern Java web
applications (the JVM languages, Java EE, and the Java web frameworks), it is time to delve into
some specifics about Java.
The following section introduces Java so you can build your first stand-alone Java application. Since
this book is centered on web development using Java and is not about Java as a programming
language, the introduction to Java is brief—it’s just enough to help newcomers to the language
follow the subsequent chapters.

Getting Started with Java


A Java application is a computer program that executes when you use the java command to
launch the JVM. In the Java programming language, all source code is first written in plain-text
files (in Notepad, for instance, or in any text editor) with the .java extension. The source files are
compiled by the javac compiler into .class files that contain bytecode instructions. The JVM reads
these bytecode instructions and translates them into the machine-language operations that each
computer executes. By making the JVM available on many platforms, Sun transformed Java into a
cross-platform language. As shown in Figure 1-6, the very same bytecode can run on any operating
system for which a JVM has been developed.

JVM for Windows

Java program Java compiler Bytecode JVM for Unix

JVM for Linux

Figure 1-6. Cross-platform Java

Because the JVM is available on many different operating systems, the same .class files are
capable of running on Windows, Unix, Linux, or Mac OS. In the section that follows, I will show you
how to compile and run your first Java application. But first you need to set up the development
environment.
12 CHAPTER 1: Introducing Java Web Development

Setting Up the Development Environment


The Java software is available in two distributions.
 The Java Runtime Environment (JRE)
 The Java Development Kit (JDK)
The JRE includes a JVM and the core libraries; it is essentially just an environment for running
bytecode. The JDK includes the JRE, a Java compiler (javac), and other tools—the basic software
you need to write and compile Java programs.
Before you can start compiling and running Java programs, you need to download and install the
JDK and configure some system environment variables.
Most of the code in this book requires Java 7, but some of the code is based on Java 8, so you
should install Java 8. To get the latest version of the JDK)), follow these steps:
1. Open www.oracle.com/technetwork/java/javase/downloads/index.html in a
web browser.
2. Click the Download JDK button.
3. Follow the instructions provided by the web site.
4. Run the installer and accept any defaults.
To confirm you have installed the JDK correctly, type javac on the command line from any directory
on your machine. If you see instructions on how to run javac correctly, then you have installed it
successfully.

Creating and Running Your First Java Application


This section demonstrates how to create, compile, and execute a simple Java application on
Windows. Every Java application has one class that is the program’s starting point (often called an
entry point). Listing 1-1 illustrates a HelloWorld entry-point class.

Listing 1-1. A HelloWorld Java Application

1. public class HelloWorld {


2. public static void main(String[] args) {
3. System.out.println("Hello World.");
4. }
5. }

 Line 2: The main method in line 2 makes this class an entry-point class. This
method accepts inputs and starts the program.
The name of the Java application should be the name of the entry-point class, and the file that holds
a Java class must have the same name as the class. Therefore, the HelloWorld class in Listing 1-1
must be stored in a file named HelloWorld.java.
CHAPTER 1: Introducing Java Web Development 13

Note Every Java application has only one main method.

You use the javac program in the bin directory of your JDK installation directory to compile Java
programs. Assuming you have edited the PATH environment variable on your computer, you should
be able to invoke javac from any directory. To compile the HelloWorld class in Listing 1-1, do the
following:
1. Open a command prompt and change to the directory where the HelloWorld.
java file is saved.
2. Type the following command:

javac HelloWorld.java

If everything goes well, javac will create a file named HelloWorld.class in your working directory.

Running Your Java Application


To run your Java application, you have to use the java program that is part of the JDK with the
command java <class name>. Again, having added the PATH environment variable, you should be
able to invoke java from any directory. From your working directory, type the following:

java HelloWorld

Note that you do not include the .class extension when running a Java application. You will see the
following on your console:

Hello World.

Developing Java Applications with an IDE


In this book you will use the Eclipse Kepler integrated development environment (IDE). To download
it, follow these steps:
1. Open www.eclipse.org/downloads/ in a web browser.
2. Follow the instructions provided by the web site.
3. Run the installer and accept any defaults.

Creating Your First Project in the IDE


After you’ve started Eclipse, you can make a new project as follows:
1. From the File menu, select New, and then select Project. The New Project
window appears.
2. In the New Project window, double-click Java Project. The New Java Project
window appears, as illustrated in Figure 1-7.
14 CHAPTER 1: Introducing Java Web Development

Figure 1-7. Creating a Java project


Discovering Diverse Content Through
Random Scribd Documents
texture. The artificers busy themselves with making columns and
slabs for pavements in edifices from it, in the same way as from
porphyry. It is never seen carved into figures, although it is very
often used for the bases of columns, the pedestals of tables, and other
works of a ruder kind. Though this sort of stone is liable to fracture,
and is harder than porphyry, it is sweeter to work and involves less
labour. Serpentine is quarried in Egypt and Greece and the sound
pieces are not very large; consequently no work of greater
dimensions than three braccia in any direction is ever seen of
serpentine, and such works as exist are slabs and pieces of pavement.
A few columns are found also but not very massive nor thick, as well
as some masks and sculptured brackets, but figures never. This stone
is worked in the same manner as porphyry.

§ 4. Of Cipollaccio.

Softer than serpentine is cipollaccio,[30] a stone quarried in various


places; it is of a crude yellowish green colour and has within it some
square black marks, large and small, and also biggish white marks.
Of this material one may see in various places columns both massive
and slender, as well as doors and other ornaments, but not figures.
There is a fountain of this stone in Rome in the Belvedere, that is to
say a niche in a corner of the garden where are the statues of the Nile
and of the Tiber;[31] Pope Clement VII had this niche made, after a
design by Michelagnolo,[32] to adorn the statue of a river god that it
might look very beautiful in this setting made in imitation of natural
rocks, as indeed it actually does. Cipollaccio is also sawn into panels,
round and oval, and into similar pieces which, when arranged with
other stones in pavements and other flat surfaces, make lovely
compositions. It takes a polish like porphyry and serpentine and is
sawn in the same manner. Numberless pieces of it are found in
Rome, buried under the ruins; these come to light daily and thus of
ancient things modern works are made, such as doors and other
ornamental details, which, wherever placed, are decorative and very
beautiful.

§ 5. Of Breccia (‘Mischio,’ Conglomerate).


Here is now another stone, called ‘mischio’ (breccia),[33] from the
mixture of various stones coagulated together and made one by time
and by the mordant action of water. It is found in abundance in
several places, as in the mountains of Verona, in those of Carrara,
and of Prato in Tuscany, and in the hills of the Impruneta in the
neighbourhood of Florence.[34] But the best and choicest breccias
have been found, not long ago, at San Giusto at Monte Rantoli, five
miles distant from Florence.[35] In this material Duke Cosimo has
commissioned me to decorate all the new rooms of the palace with
doors and chimney pieces, and the effect is most beautiful. Also for
the garden of the Pitti, very fine columns seven braccia high have
been quarried from the same place, and I am astonished that in this
stone such large pieces should be found free from flaws.[36] Being of
the nature of limestone, it takes a beautiful polish and in colour
inclines to a reddish purple streaked with white and yellowish veins.
But the finest examples of all are in Greece and Egypt,[37] where the
stone is much harder than ours in Italy, and it is found in as many
different colours as mother nature has delighted and still delights to
produce in all perfection. In the breccias formed in this way one sees
at Rome at the present day both ancient and modern works, such as
columns, vases, fountains, door ornaments, and various inlays on
buildings, as well as many pieces in the pavements. There are various
sorts, of many colours; some draw to yellow and red, others to white
and black, others again to grey and white speckled with red and
veined with numerous colours; then there are certain reds, greens,
blacks and whites which are oriental: and of this sort of stone the
Duke has an antique urn, four and a half braccia across, in his garden
at the Pitti, a thing most precious, being as I said of oriental breccia
very beautiful and extremely hard to work.[38] Such stones are all very
hard, and exquisite in colour and quality, as is shown by the two
columns, twelve braccia high at the entrance of St. Peter’s in Rome,
which support the first arcades of the aisles, one on each side.[39] Of
this stone, the kind which is found in the hills of Verona, is very
much softer than the oriental; and in that place is quarried a sort
which is reddish, and inclines towards a vetch colour.[40] All these
kinds are worked easily in our days with the tempering-baths and the
tools used for our own local stones. Windows, columns, fountains,
pavements, door posts and mouldings are made of them, as is seen in
Lombardy and indeed throughout Italy.
§ 6. Of Granite.

There is another sort of extremely hard stone, much coarser and


speckled with black and white and sometimes with red, which, on
account of its grain and consistency, is commonly called granite.[41]
In Egypt it exists in solid masses of immense size that can be
quarried in pieces incredibly long, such as are seen now-a-days in
Rome in obelisks, needles, pyramids, columns, and in those
enormous vessels for baths which we have at San Pietro in Vincola,
at San Salvadore del Lauro and at San Marco.[42] It is also seen in
columns without number, which for hardness and compactness have
had nothing to fear from fire or sword, so that time itself, that drives
everything to ruin, not only has not destroyed them but has not even
altered their colour. It was for this reason that the Egyptians made
use of granite in the service of their dead, writing on these obelisks in
their strange characters the lives of the great, to preserve the
memory of their prowess and nobility.
From Egypt there used also to come another variety of grey
granite, where the black and white specks draw rather towards green.
It is certainly very hard, not so hard however, but that our
stonecutters, in the building of St. Peter’s, have made use of the
fragments they have found, in such a manner that by means of the
temper of the tools at present adopted, they have reduced the
columns and other pieces to the desired slenderness and have given
them a polish equal to that of porphyry.
Many parts of Italy are enriched with this grey granite, but the
largest blocks found are in the island of Elba, where the Romans kept
men continually employed in quarrying countless pieces of this rock.
[43]
Some of the columns of the portico of the Ritonda are made of it,
and they are very beautiful and of extraordinary size.[44] It is noticed
that the stone when in the quarry is far softer and more easy to work
than after it has lain exposed.[45] It is true that for the most part it
must be worked with picks that have a point, like those used for
porphyry, and at the other end a sharp edge like a toothed chisel.[46]
From a piece of this granite which was detached from the mass, Duke
Cosimo has hollowed out a round basin twelve braccia broad in every
direction and a table of the same length for the palace and garden of
the Pitti.[47]
§ 7. Of Paragon (Touchstone).[48]

A kind of black stone, called paragon, is likewise quarried in Egypt


and also in some parts of Greece. It is so named because it forms a
test for trying gold; the workman rubs the gold on this stone and
discerns its colour, and on this account, used as it is for comparing or
testing, it comes to be named paragon, or indexstone (a). Of this
there is another variety, with a different grain and colour, for it has,
almost but not quite, the tint of the mulberry, and does not lend itself
readily to the tool. It was used by the ancients for some of those
sphinxes and other animals seen in various places in Rome, and for a
figure of greater size, a hermaphrodite in Parione,[49] alongside of
another most beautiful statue of porphyry.[50] This stone is hard to
carve, but is extraordinarily beautiful and takes a wonderful polish
(b). The same sort is also to be found in Tuscany, in the hills of Prato,
ten miles distant from Florence (c), and in the mountains of Carrara.
On modern tombs many sarcophagi and repositories for the dead are
to be seen of it; for example, in the principal chapel in the Carmine at
Florence, where is the tomb of Piero Soderini (although he is not
within it) made of this stone, and a canopy too of this same Prato
touchstone, so well finished and so lustrous that it looks like a piece
of satin rather than a cut and polished stone (d). Thus again, in the
facing which covers the outside of the church of Santa Maria del
Fiore in Florence, all over the building, there is a different kind of
black marble (e) and red marble (f), but all worked in the same
manner.

§ 8. Of Transparent Marbles for filling window openings.

Some sorts of marble are found in Greece and in all parts of the
East, which are white and yellowish, and very transparent. These
were used by the ancients for baths and hot-air chambers and for all
those places which need protection against wind, and in our own
days there are still to be seen in the tribune of San Miniato a Monte,
the abode of the monks of Monte Oliveto, above the gates of
Florence, some windows of this marble, which admit light but not
air.[51] By means of this invention people gave light to their dwellings
and kept out the cold.
§ 9. Of Statuary Marbles.

From the same quarries[52] were taken other marbles free from
veins, but of the same colour, out of which were carved the noblest
statues. These marbles were of a very fine grain and consistency, and
they were continually being made use of by all who carved capitals
and other architectural ornaments. The blocks available for sculpture
were of great size as appears in the Colossi of Montecavallo at Rome,
[53]
in the Nile[54] of the Belvedere and in all the most famous and
noble statues. Apart from the question of the marble, one can
recognize these to be Greek from the fashion of the head, the
arrangement of the hair, and from the nose, which from its juncture
with the eyebrows down to the nostril is somewhat square.[55] This
marble is worked with ordinary tools and with drills, and is polished
with pumice stone, with chalk from Tripoli, and with leather and
wisps of straw.
In the mountains of Carrara in the Carfagnana,[56] near to the
heights of Luni, there are many varieties of marble, some black,[57]
some verging towards grey, some mingled with red and others again
with grey veins.[58] These form an outer crust over the white marbles,
and they take those colours, because they are not refined, but rather
are smitten by time, water and the soil. Again, there are other sorts of
marble, called ‘cipollini,’[59] ‘saligni,’ ‘campanini’ and ‘mischiati.’[60]
The most abundant kind is pure white and milky in tone; it is easy to
work and quite perfect for carving into figures. Enormous blocks lie
there ready to be quarried, and in our own days, pieces measuring
nine braccia have been hewn out for colossal statues. Two of these
colossi have recently been sculptured, each from a single block. The
one is Michelagnolo’s ‘David,’ which is at the entrance of the Ducal
Palace in Florence;[61] the other is the ‘Hercules and Cacus’ from the
hand of Bandinello standing at the other side of the same entrance.
Another block of nine braccia in length was taken out of the quarry a
few years ago, in order that the same Baccio Bandinello should carve
a figure of Neptune for the fountain which the Duke is having erected
on the piazza. But, Bandinello being dead, it has since been given to
Ammannato, an excellent sculptor, for him likewise to carve a
Neptune out of it.[62] But of all these marbles, that of the quarry
named Polvaccio,[63] in the place of that name, has the fewest
blemishes and veins and is free from those knots and nuts which very
often occur in an extended surface of marble—occasioning no little
difficulty to the worker, and spoiling the statues even when they are
finished. From the quarries of Seravezza, near to Pietrasanta, there
have been taken out a set of columns, all of the same height, destined
for the façade of San Lorenzo at Florence, which is now sketched out
in front of the door of that church;[64] one of these columns is to be
seen there, the rest remain, some in the quarry, some at the
seashore.

Fig. 2.—Tools mentioned by Vasari, etc.

A, B, Models of Tools used in Egypt at the present day for


working hard stones.
C, The pick referred to by Vasari, p. 41.
D, A burin or graver.
E-J, Tools in actual use in a stone-cutter’s yard at Settignano:

E, Subbia, a point.
F, Calcagnuolo, a toothed chisel.
G, Gradina, a broader toothed chisel.
H, Scarpello, a chisel.
J, Trapano, a drill.
But returning to the quarries of Pietrasanta,[65] I say that they were
the quarries in which all the ancients worked, and no other marbles
but these were used for their statues by those masters, who were so
excellent. While the masses were being hewn out, they were always at
work, blocking out figures in the rough on the stones while they were
still in the quarry. The remains of many of these can be seen even yet
in that place.[66] This same marble, then, the moderns of to-day use
for their statues, not only in Italy, but in France, England, Spain and
Portugal, as can be seen to-day in the tomb executed in Naples by
Giovanni da Nola, the excellent sculptor, for Don Pietro di Toledo,
viceroy of that kingdom, to whom all the marbles were presented,
and sent to Naples by Duke Cosimo de’ Medici.[67] This kind of
marble has in itself larger available pieces and is more yielding and
softer to work and receives a finer polish than any other marble. It is
true that occasionally the workman meets with flaws called by the
sculptors ‘smerigli’ (emery veins) which usually cause the tools to
break. The blocks are first roughed into shape, by a tool called
‘subbia’ (point)[68] which is pointed like a stake in facets, and is
heavier or lighter as the case may be. At the next stage are used
chisels, named ‘calcagnuoli’ (toothed chisels), which have a notch in
the middle of the edge of the blade; after that finer and finer tools
with more teeth are used to score the marble, after which it is
smoothed with another chisel called ‘gradina,’ (broader toothed
chisel) used to reduce and refine the figures. The tooth marks left in
the marble are removed with iron rasps straight and curved, and
thus at last, by polishing gradually with pumice stone the surface
aimed at is attained. In order not to fracture the marble, all the drill-
holes are made with drills of different sizes weighing from twelve
pounds each even to twenty, according to the size of the hole needed,
[69]
and they serve to finish every sort of work and to bring it to
perfection.
Of certain white marbles, streaked with grey,[70] sculptors and
architects make ornaments for doors and columns for houses and the
same are used also for pavements and for facings of large buildings,
and for all sorts of things. All the marbles called ‘mischiati’[71] are
used for the same purposes.
§ 10. Of Cipollino Marble.[72]

The cipollini marbles are another kind, different in grain and


colour, and found in other places besides Carrara. Most of them are
greenish, and full of veins; they are useful for various things, but not
for figures. Those which the sculptors call ‘saligni,’[73] because they
are partly transparent, and have that lustrous appearance seen in
salt, have something of the nature of stalagmite, and are troublesome
enough to make figures of; because the grain of the stone is rough
and coarse, or because in damp weather water drops from it
continually or else it sweats. The ‘campanini’ marbles are so named
because they sound like a bell under the hammer and give out a
sharper note than other marbles.[74] These are hard and crack more
easily than the kinds above mentioned. They are quarried at
Pietrasanta.[75] Again at Seravezza[76] in many places and at
Campiglia[77] there are marbles excavated, which are for the most
part excellent for ashlar work and even fairly good sometimes for
statues.

§ 11. Of White Pisan Marble.

A kind of white marble, akin to limestone, is found likewise at


Monte San Giuliano near Pisa.[78] It has been used for covering the
outside walls of the Duomo and the Camposanto of Pisa, as well as
for many other ornaments to be seen in that city. Formerly the said
marbles were brought to Pisa from the hill at San Giuliano with
trouble and expense, but now it is different, because Duke Cosimo, in
order to make the district more healthy and also to facilitate the
carriage of the marbles and other stones taken from those
mountains, has turned into a straight canal the river Osoli and many
other streams, which used to rise in those plains and do damage to
the country. By means of this canal, the marbles, either worked or
rough, can be easily conveyed, at a trifling cost, and with the greatest
advantage to the city which is now almost restored to its former
magnificence, thanks to the said Duke, who has no object more dear
to him than that of improving and restoring the city, which was
falling into ruins, before His Excellency became its lord.[79]
§ 12. Of Travertine.

There is another sort of stone called travertine, which is much


used for building and also for carvings of various sorts. It is always
being quarried in many places throughout Italy, as in the
neighbourhood of Lucca, at Pisa, and round about Siena; but the
largest blocks and the best, that is, those which are most easily
worked, are taken from above the river Teverone at Tivoli.[80] The
stone is all a kind of coagulation of earth and of water, which by its
hardness and coldness congeals and petrifies not only earth, but
stumps and branches and leaves of trees. On account of the water
that remains within the stones—which never can be dry so long as
they lie under water—they are full of pores which give them a spongy
and perforated appearance, both within and without.
Of travertine the ancients constructed their most wonderful
buildings, for example, the Colosseum, and the Treasury by the
church of Ss. Cosimo e Damiano[81] and many other edifices. They
used it without stint for the foundations of their public buildings,
and in working these basements, they were not too fastidious in
finishing them carefully, but left them rough, as in rustic work; and
this they did perhaps because so treated they possess a certain
grandeur and nobility of their own.[82] But in our days there has been
found one who has worked travertine most skilfully, as was formerly
seen in that round temple, begun but never finished, save only the
basement, on the piazza of San Luigi de’ Francesi in Rome.[83] It was
undertaken by a Frenchman named Maestro Gian, who studied the
art of carving in Rome and became so proficient, that his work in the
beginning of this temple could stand comparison with the best
things, either ancient or modern, ever seen carved in travertine. He
carved astrological globes, salamanders in the fire, royal emblems,
devices of open books showing the leaves, and carefully finished
trophies and masks. These, in their own place, bear witness to the
excellence and quality of the stone which, although it is coarse, can
be worked as freely as marble. It possesses a charm of its own, owing
to the spongy appearance produced by the little cavities which cover
the surface and look so well. This unfinished temple being left
imperfect, was razed by the French, and the said stones and other
pieces that formed part of its construction were placed in the façade
of the church of San Luigi[84] and in some of its chapels, where they
are well arranged, and produce a beautiful effect.
Travertine is excellent for walls, because after it is built up in
squared courses and worked into mouldings, it can be entirely
covered with stucco[85] and thereafter be impressed with any designs
in relief that are desired, just as the ancients did in the public
entrances to the Colosseum[86] and in many other places; and as
Antonio da San Gallo has done in the present day in the hall of the
Pope’s palace, in front of the chapel,[87] where he has faced the
travertine with stucco bearing many excellent devices. More than any
other master however has Michelagnolo Buonarroti ennobled this
stone in the decoration of the court of the Casa Farnese.[88] With
marvellous judgement he has used it for windows, masks, brackets,
and many other such fancies; all these are worked as marble is
worked and no other similar ornament can be seen to excel this in
beauty. And if these things are rare, more wonderful than all is the
great cornice on the front façade of the same palace, than which
nothing more magnificent or more beautiful can be sought for.
Michelagnolo has also employed travertine for certain large chapels
on the outside of the building of St. Peter’s, and in the interior, for
the cornice that runs all round the tribune; so finished is this cornice
that not one of the joints can be perceived, everyone therefore can
well understand with what advantage to the work we employ this
kind of stone. But that which surpasses every other marvel is the
construction in this stone of the vault of one of the three tribunes in
St. Peter’s; the pieces composing it are joined in such a manner that
not only is the building well tied together with various sorts of bonds,
but looked at from the ground it appears made out of a single piece.
[89]

§ 13. Of Slates.

We now come to a different order of stones, blackish in colour and


used by the architects only for laying on roofs. These are thin flags
produced by nature and time near the surface of the earth for the
service of man. Some of these are made into receptacles, built up
together in such a manner that the pieces dovetail one into the other.
The vessels are filled with oil according to their holding capacity and
they preserve it most thoroughly. These slates are a product of the
sea coast of Genoa, in a place called Lavagna;[90] they are excavated
in pieces ten braccia long and are made use of by artists for their oil
paintings, because pictures painted on slate last much longer than on
any other material, as we shall discuss more appropriately in the
chapters on painting.

§ 14. Of Peperino.[91]

We shall also refer in a future chapter to a stone named piperno or


more commonly peperigno, a blackish and spongy stone, resembling
travertine, which is excavated in the Roman Campagna. It is used for
the posts of windows and doors in various places, notably at Naples
and in Rome; and it also serves artists for painting on in oil, as we
shall relate in the proper place. This is a very thirsty stone and
indeed more like cinder than anything else.

§ 15. Of the Stone from Istria.[92]

There is moreover quarried in Istria a stone of a livid white, which


very easily splits, and this is more frequently used than any other,
not by the city of Venice alone, but by all the province of Romagna,
for all works both of masonry and carving. It is worked with tools
and instruments longer than those usually employed, and chiefly
with certain little hammers that follow the cleavage of the stone,
where it readily parts. A great quantity of this kind of stone was used
by Messer Jacopo Sansovino, who built the Doric edifice of the
Panattiera[93] in Venice, and also that in the Tuscan style for the
Zecca (mint) on the Piazza of San Marco.[94] Thus they go on
executing all their works for that city, doors, windows, chapels, and
any other decorations that they find convenient to make,
notwithstanding the fact that breccias and other kinds of stone could
easily be conveyed from Verona, by means of the river Adige. Very
few works made of these latter materials are to be seen, because of
the general use of the Istrian stone, into which porphyry, serpentine
and other sorts of breccias are often inlaid, resulting in compositions
which are very ornamental. This stone is of the nature of the
limestone called ‘alberese,’ not unlike that of our own districts, and
as has been said it splits easily.

§ 16. Of Pietra Serena.

There only remains now the pietra serena and the grey stone called
‘macigno’[95] and the pietra forte which is much used in the
mountainous parts of Italy, especially in Tuscany, and most of all in
Florence and her territory. The stone that they call pietra serena[96]
draws towards blue or rather towards a greyish tint. There are
quarries of it in many places near Arezzo, at Cortona, at Volterra, and
throughout the Apennines. The finest is in the hills of Fiesole, and it
is obtained there in blocks of very great size, as we see in all the
edifices constructed in Florence by Filippo di Ser Brunellesco, who
had all the stones needed for the churches of San Lorenzo and of
Santo Spirito quarried there, and also an unlimited quantity which
are in every building throughout the city. It is a very beautiful stone
to look at, but it wastes away and exfoliates where it is subjected to
damp, rain, or frost. Under cover however it will last for ever. Much
more durable than this and of finer colour is a sort of bluish stone, in
our day called ‘pietra del fossato.’[97] When quarried, the first layer is
gravelly and coarse, the second is never free from knots and fissures,
the third is admirable being much finer in grain. Michelagnolo used
this, because of its yielding grain, in building the Library and Sacristy
of San Lorenzo for Pope Clement, and he has had the mouldings,
columns, and every part of the work executed with such great care
that even if it were of silver it would not look so well.[98] The stone
takes on a very fine polish, so much so that nothing better in this
kind of material could be wished for. On this account it was
forbidden by law that the stone be used in Florence for other than
public buildings, unless permission had been obtained from the
governing authorities.[99] The Duke Cosimo has had a great quantity
of this stone put into use, as for example, in the columns and
ornaments of the loggia of the Mercato Nuovo, and for the work
begun by Bandinello in the great audience chamber of the palace and
also in the other hall which is opposite to it; but the greatest amount,
more than ever used elsewhere, has been taken by his Excellency for
the Strada de’ Magistrati,[100] now in construction, after the design
and under the direction of Giorgio Vasari of Arezzo. This stone
demands as much time for working it as marble. It is so hard that
water does not affect it and it withstands all other attacks of time.
Besides this there is another sort called pietra serena, found all
over the hill, which is coarser, harder, and not so much coloured, and
contains certain knots in the stone. It resists the influence of water
and frost, and is useful for figures and carved ornaments. Of this is
carved La Dovizia (Abundance), a figure from the hand of Donatello
on the column of the Mercato Vecchio in Florence;[101] and it serves
also for many other statues executed by excellent sculptors, not only
in this city, but throughout the territory.

§ 17. Of Pietra Forte.[102]

The pietra forte is quarried in many places; it resists rain, sun,


frost, and every trial, and demands time to work it, but it behaves
very well; it does not exist in very large blocks.[103] Both by the
Goths[104] and by the moderns have been constructed of this stone the
most beautiful buildings to be found in Tuscany, as can be seen in
Florence in the filling of the two arches, which form the principal
doors of the oratory of Orsanmichele,[105] for these are truly
admirable things and worked with the utmost care. Of this same
stone there are throughout the city, as has been said, many statues
and coats of arms,[106] as for instance in the Fortress and various
other places. It is yellowish in colour with fine white veins that add
greatly to its attractiveness, and it is sometimes employed for statues
where there are to be fountains, because it is not injured by water.
The walls of the palace of the Signori, the Loggia, and Orsanmichele
are built of it, also the whole interior of the fabric of Santa Maria del
Fiore, as well as all the bridges of our city, the Palace of the Pitti and
that of the Strozzi families. It has to be worked with picks because it
is very compact. Similarly, the other stones mentioned above must
be treated in the manner already explained for the working of marble
and other sorts of stones.

§ 18. Conclusion of Chapter.


After all however, good stones and well tempered tools apart, the
one thing essential is the art, the intelligence, and the judgement of
those who use them, for there is the greatest difference between
artists, although they may all use the same method, as to the
measure of grace and beauty they impart to the works which they
execute. This enables us to discern and to recognize the perfection of
the work done by those who really understand, as opposed to that of
others who know less. As, therefore, all the excellence and beauty of
the things most highly praised consist in that supreme perfection
given to them by those who understand and can judge, it is necessary
to strive with all diligence always to make things beautiful and
perfect—nay rather, most beautiful and most perfect.
CHAPTER II.
The Description of squared Ashlar-work (lavoro di quadro) and of
carved Ashlar-work (lavoro di quadro intagliato).

§ 19. The work of the Mason.

Having thus considered all the varieties of stone, which our


artificers use either for ornament or for sculpture, let us now go on to
say, that when stone is used for actual building, all that is worked
with square and compasses and that has corners is called squared
ashlar work (lavoro di quadro). The term (quadro) is given, because
of the squared faces and corners, for every order of moulding or
anything which is straight, projecting, or rectangular is work which
takes the name of ‘squared,’ and so is it commonly known among the
artificers. But when the stone does not remain plain dressed, but is
chiselled into mouldings, friezes, foliage, eggs, spindles, dentels and
other sorts of carving, the work on the members chosen to be so
treated is called by the mason carved ashlar work (opera di quadro
intagliato or lavoro di intaglio). Of this sort of plain and carved
ashlar are constructed all the different Orders, Rustic, Doric, Ionic,
Corinthian, and Composite, and so too, in the times of the Goths, the
German work[107] (lavoro tedesco): and no kind of ornament can be
made that is not founded on both sorts of the work above described.
It is the same with breccias and marbles and every sort of stone, and
also with bricks, used as a foundation for moulded stucco work. The
same applies to walnut, poplar, and every kind of wood. But, because
many do not recognize the difference between one Order and
another, let us discuss distinctly and as briefly as possible in the
chapter which follows, every mode and manner of these.
CHAPTER III.
Concerning the five Orders of Architecture, Rustic, Doric, Ionic,
Corinthian, Composite, and also German Work.

§ 20. Rusticated masonry and the Tuscan Order.

The work called Rustic[108] is more stunted, and more massive than
that of any other Order, it being the beginning and foundation of all.
The profiles of the mouldings are simpler and in consequence more
beautiful, as are the capitals and bases as well as every other
member. The Rustic socles or pedestals, as we call them, on which
rest the columns, are square in proportion, with a solid moulding at
the foot and another above which binds it like a cornice. The height
of the column measures six heads,[109] in imitation of people who are
dwarfed and adapted to sustain weights. Of this Order there are to be
seen in Tuscany many colonnades both plain and rusticated, with
and also without bosses and niches between the columns: and many
porticoes which the ancients were accustomed to construct in their
villas; and in the country one still sees many tombs of the kind as at
Tivoli and at Pozzuolo. This Order served the ancients for doors,
windows, bridges, aqueducts, treasuries, castles, towers, and
strongholds for storing ammunition and artillery; also for harbours,
prisons and fortresses; in these the stones project in an effective
manner in points like a diamond, or with many facets. The
projections are treated in various ways, either in bosses, flattened, so
as not to act as a ladder on the walls—for it would be easy to climb up
if the bosses jutted out too much—or in other ways, as one sees in
many places, and above all in Florence, in the principal façade of the
chief citadel, built by Alexander, first duke of Florence.[110] This
façade, out of respect to the Medici emblems, is made with
ornaments of diamond points and flattened pellets, but both in low
relief. The wall composed of pellets and diamonds side by side is very
rich and varied and most beautiful to look at. There is abundance of
this work at the villas of the Florentines, the gates and entrances, and
at the houses and palaces where they pass the summer, which not
only beautify and adorn that neighbourhood, but are also of the
greatest use and convenience to the citizens. But much more is the
city itself enriched with magnificent buildings, decorated with
rusticated masonry, as for example the Casa Medici, the façade of the
Pitti Palace, the palace of the Strozzi family and innumerable others.
When well designed, the more solid and simple the building, the
more skill and beauty do we perceive in it, and this kind of work is
necessarily more lasting and durable than all others, seeing that the
pieces of stone are bigger and the assemblage much better, all the
building being in bond, one stone with another. Moreover, because
the members are smooth and massive, the chances of fortune and of
weather cannot injure them so severely as the stones that are carved
and undercut, or, as we say here, ‘suspended in the air’ by the
cleverness of the sculptors.
Fig. 3.—Fortezza da Basso at Florence.

§ 21. The Doric Order.


Fig. 4.—Rusticated masonry on the exterior of the Fortezza da Basso at Florence.

The Doric Order was the most massive known to the Greeks, more
robust both as to strength and mass, and much less open than their
other Orders. And not only the Greeks but the Romans also
dedicated this sort of building to those who were warriors, such as
generals of armies, consuls, praetors—and much more often to their
gods, as Jove, Mars, Hercules and others. According to the rank and
character of these the buildings were carefully distinguished—made
plain or carved, simple or rich—so that all could recognize the grade
and the position of the different dignitaries to whom they were
dedicated,[111] or of him who ordered them to be built. Consequently
one sees that the ancients applied much art in the composition of
their buildings, that the profiles of the Doric mouldings are very
graceful, and the features harmonious and of a high degree of
beauty; and also that the proportion of the shafts of the columns is
very well understood, as they are neither too thick nor too thin. The
form of the columns, as is commonly said, resembles that of
Hercules; it shows a certain solidity capable of sustaining the weight
of the architraves, friezes, cornices and the rest of the upper parts of
the building. Because this Order, as more secure and stable than the
others, has always much pleased Duke Cosimo, he desires that the
building, which he has charged me to construct for thirteen civil
magistrates of his city and dominion, should be of the Doric Order.
This building is to have splendid decoration in stone, and is to be
placed between his own palace and the river Arno.[112] Therefore, in
order to bring back into use the true mode of construction, which
requires the architraves to lie level over the columns, and avoid the
falsity of turning the arches of the arcades above the capital, I have
followed in the principal façade the actual method of the ancients, as
can be seen in the edifice. This fashion of building has been avoided
by architects of the recent past, because stone architraves of every
sort both ancient and modern are all, or the greater part of them,
seen to be broken in the middle, notwithstanding that above the solid
of the columns and of the architraves, frieze, and cornice, there are
flat arches of brick that are not in contact with and do not load the
work below. Now, after much consideration on the whole question, I
have finally found an excellent way of putting into use the true mode
of proceeding so as to give security to the said architraves, by which
they are prevented from suffering in any part and everything remains
as sound and safe as can be desired, as the result has proved. This
then, is the method, that is stated here below for the benefit of the
world at large and of the artificers.

Fig. 5.—Construction of the portico of the Uffizi at Florence, from Vasari’s


description.
§ 22. A constructive device to avoid charging architraves.
[113]

Having set up the columns, and above the capitals the architraves,
which are brought into contact the one with the other above the
middle axis of the column, the builder proceeds to make a square
block or die (D, D, Fig. 5). For example, if the column be a braccio
thick and the architraves the same in width[114] and height, let the die
in the frieze be made equal to them; but in front let there remain an
eighth in the face for the vertical joint, and let another eighth or
more have a sinking into the die on each side, bevelled to an angle of
45°, Fig. 5 (1). Then since the frieze in each intercolumniation is in
three pieces (B, A, B), let the two at the sides (B, B) have bevelled
projections in the opposite sense to the sinkings, increasing from
within outwards, Fig. 5 (2), so that each may be mortised in the die
and be keyed after the manner of an arch, and in the front the
amount of the eighth must bond vertically; while the part on the
other side must do the same to the other die. And so above the
column[115] one must arrange that the piece in the middle of the said
frieze closes within and is recessed in quarter-round form up to the
middle, while the other half must be squared and straight and set
with an empty space below, in order that it may hold as does an arch,
the wall on the external face appearing worked with vertical joints.
[116]
Do not let the stones of the said frieze rest on the architrave, but
let a finger’s breadth be between them; in this way, making an arch,
the frieze comes to support itself and does not burden the architrave.
Afterwards make on the inside, for filling up the said frieze, a flat
arch of bricks as high as the frieze, that stretches from die to die
above the columns. Then make a piece of cornice as wide as the
die[117] above the columns, which has the joints in front like those of
the frieze, and within let the said cornice be keyed like the blocks of
the frieze, care being taken to make the cornice, as the frieze, in three
pieces, of which the two at the sides hold from within the middle
piece of the cornice above the die of the frieze,[118] and mind that the
middle piece of the cornice, C, C, slips down into the sinkings so as to
span the void, and unites the two pieces at the sides so as to lock
them in the form of an arch. In this fashion everyone can see that the
frieze sustains itself, as does the cornice, which rests almost entirely
on the arch of bricks.[119] Thus one thing helping another, it comes
about that the architrave does not sustain any but its own weight, nor
is there danger of its ever being broken by too heavy a load. Because
experience shows this method to be the most sure, I have wished to
make particular mention of it, for the convenience and benefit of all;
especially as I know that when the frieze and the cornice were put
above the architrave as was the practice of the ancients, the latter
broke in course of time, possibly on account of an earthquake or
other accident, the arch of discharge which was introduced above the
cornice not being sufficient to preserve it. But throwing the arches
above the cornices made in this form, and linking them together with
iron, as usual,[120] secures the whole from every danger and makes
the building endure eternally.
Returning to the matter in hand, let us explain then that this
fashion of work may be used by itself alone, or can be employed in
the second floor from the ground level, above the Rustic Order, or it
can be put higher up above another variety of Order such as Ionic,
Corinthian or Composite, in the manner shown by the ancients in the
Colosseum in Rome, in which arrangement they used skill and
judgement. The Romans, having triumphed not only over the Greeks
but over the whole world, put the Composite Order at the top, of
which Order the Tuscans have composed many varieties. They placed
it above all, as superior in force, grace, and beauty, and as more
striking than the others, to be a crown to the building; for to be
adorned with beautiful members gives to the work an honourable
completion and leaves nothing more to be desired.

§ 23. The proportions and parts of the Doric Order.

To return to the Doric Order, I may state that the column is made
seven heads in height. Its pedestal must be a little less than a square
and a half in height and a square in width,[121] then above are placed
its mouldings and beneath its base with torus and two fillets, as
Vitruvius directs. The base and capital are of equal height, reckoning
the capital from the astragal upwards. The cornice with the frieze
and architrave attached projects over every column, with those
grooved features, usually called triglyphs, which have square
spaces[122] interposed between the projections, within which are the
skulls of oxen, or trophies, or masks, or shields, or other fancies. The
architrave, jutting out, binds these projections with a fillet, and
under the fillet are little strips square in section, at the foot of each of
which are six drops, called by the ancients ‘guttae’ (goccie). If the
column in the Doric order is to be seen fluted, there must be twenty
hollow facets instead of flutes,[123] and nothing between the flutes but
the sharp arris. Of this sort of work there is an example in Rome at
the Forum Boarium which is most rich;[124] and of another sort are
the mouldings and other members in the theatre of Marcellus, where
to-day is the Piazza Montanara, in which work there are no bases (to
the Doric columns) and those bases which are visible are Corinthian.
It is thought that the ancients did not make bases, but instead placed
there a pedestal of the same size as the base would have been. This is
to be met with in Rome by the prison of the Tullianum where also are
capitals richer in members than others which appear in the Doric
Order.[125] Of this same order Antonio da San Gallo has made the
inner court of the Casa Farnese in the Campo di Fiore at Rome,
which is highly decorated and beautiful; thus one sees continually
ancient and modern temples and palaces in this style, which for
stability and assemblage of the stones have held together better and
lasted longer than all other edifices.
Fig. 6.—Drawing by Giuliano da San Gallo of a
portion of the Basilica Aemilia in the Roman
Forum, that survived to the time of Vasari.

§ 24. The Ionic Order.

The Ionic Order, more slender than the Doric, was made by the
ancients in imitation of persons who stand mid-way between the
fragile and the robust; a proof of this is its adoption in works
dedicated to Apollo, Diana, and Bacchus, and sometimes to Venus.
The pedestal which sustains the column is one and a half squares
high and one wide, and the mouldings, above and below, are in
accordance with this Order. Its column measures in height eight
times the head, and its base is double with two tori, as described by
Vitruvius in the third chapter of his third book. Its capital with its
volutes or scrolls or spirals, as anyone may call them, should be well
turned, as one sees in the theatre of Marcellus in Rome, above the
Doric Order; and its cornice adorned with modillions and with
dentils, and its frieze slightly convex
(pulvinated). Should it be desired to
flute the columns, there must be
twenty-four flutes, but divided in such
a manner as to leave between each two
of them a flat piece that measures the
fourth part of the flute. This order has
in itself the most beautiful lightness
and grace and is consequently adopted
by modern architects.

§ 25. The Corinthian Order.

The Corinthian style was invariably a


favourite among the Romans, who
delighted in it so greatly that they
chose this Order for their most
elaborate and most prized buildings to
remain as a memorial of themselves; as
is seen in the Temple at Tivoli above
the Teverone, in the remains of the
temple of Peace,[126] in the arch of Pola,
Fig. 7.—Roman Doric cap, with and in that of the harbour of Ancona;
stucco finish, at S. Nicola in but much more beautiful is the
Carcere, Rome. Pantheon, that is the Ritonda of Rome.
This Order is the richest and most
decorated of all the Orders spoken of above. The pedestal that
supports the column is measured in the following way; a square and
two thirds wide (high)[127] and the mouldings above and below in
proportion, according to Vitruvius[128]: the height of the column nine
heads with base and capital, which last shall be in height the
diameter of the column at the foot, and its base half of the said
thickness. This base the ancients used to carve in various ways. Let
the ornament of the capital be fashioned with its tendrils and its
leaves, as Vitruvius directs in the fourth book, where he records that
this capital has been taken from the tomb of a Corinthian girl. Then
follow its proper architrave, frieze and cornice measured as he
describes, all carved with the modillions and ovolos and other sorts
of carving under the drip. The friezes of this Order may be carved
with leafage, or again they may be plain, or adorned with letters of
bronze let into marble, as those on the portico of the Ritonda. There
are twenty-six flutes in the Corinthian columns, although sometimes
also there are fewer, and the fourth part of the width of each flute
remains flat between every two, as is evident in many ancient works
and in modern works copied from the ancients.

§ 26. The Composite Order.

The Composite Order, although Vitruvius has not made mention of


it—having taken account of none others than the Doric, Ionic,
Corinthian, and Tuscan, and holding those artists lawless, who,
taking from all four Orders, constructed out of them bodies that
represented to him monsters rather than men—the Composite Order
has nevertheless been much used by the Romans and in imitation of
them by the moderns. I shall therefore proceed, to the end that all
may have notice of it, to explain and give the proportions of buildings
in this Order also, for I am convinced of this, that if the Greeks and
Romans created these first four Orders and reduced them to a
general rule and measure, there may have been those who have done
the same for the Composite Order, forming of it things much more
graceful than ever did the ancients.
As an example of the truth of this I quote the works of
Michelagnolo Buonarroti in the Sacristy and Library of San Lorenzo
in Florence, where the doors, niches, bases, columns, capitals,
mouldings, consoles and indeed all the details, have received from
him something of the new and of the Composite Order, and
nevertheless are wonderful, not to say beautiful. The same merit in
even greater measure is exhibited by the said Michelagnolo in the
second story of the Court of the Casa Farnese[129] and again in the
cornice which supports on the exterior the roof of that palace. He
who wishes to see in this manner of work the proof of this man’s
excellence—of truly celestial origin—in art and design of various
kinds, let him consider that which he has accomplished in the fabric
of St. Peter’s in compacting together the body of that edifice and in
making so many sorts of various and novel ornaments, such
beautiful profiles of mouldings, so many different niches and
numerous other things, all invented by him and treated differently
from the custom of the ancients. Therefore no one can deny that this
new Composite Order, which through Michelagnolo has attained to
such perfection, may be worthily compared with the others. In truth,
the worth and capacity of this truly excellent sculptor, painter, and
architect have worked miracles wherever he has put forth his hand.
Besides all the other things that are clear as daylight, he has rectified
sites which were out of the straight and reduced to perfection many
buildings and other objects of the worst form, covering with lovely
and fanciful decoration the defects of nature and art.[130] In our days
certain vulgar architects, not considering these things judiciously
and not imitating them, have worked presumptuously and without
design almost as if by chance, without observing ornament, art, or
any order. All their things are monstrous and worse than the
German.
Returning now to our subject, it has become usual for this manner
of work to be called by some the ‘Composite,’ by others the ‘Latin,’
and by others again the ‘Italic’ Order. The measure of the height of
this column must be ten heads, the base the half of the diameter of
the column, measured in the same way as the Corinthian column, as
we see in the arch of Titus Vespasianus in Rome. And he who wishes
to make flutes in this column can do so, following the plan of the
Ionian or Corinthian column—or in any way that pleases him who
adopts this style of architecture, which is a mixture of all the Orders.
The capitals may be made like those of the Corinthian except that the
echinus moulding of the capital must be larger and the volutes or
tendrils somewhat larger, as we see in the above mentioned arch.
The architrave must be three quarters of the thickness of the column
and the rest of the frieze supplied with modillions, and the cornice
equal to the architrave, because the projection gives the cornice an
increase of size, as one sees in the uppermost story of the Roman
Colosseum; and in the said modillions grooves can be cut after the
manner of triglyphs, and there can be other carving according to the
taste of the architect; the pedestal on which the column rests must be
two squares high, with the mouldings just as he pleases.

§ 27. Of Terminal Figures.


The ancients were accustomed to use for doors or sepulchres or
other kinds of enrichment, various sorts of terminal figures instead
of columns, here a figure which has a basket on the head for capital,
there a figure down to the waist, the rest, towards the base, a cone or
a tree trunk; in the same way they made virgins, chubby infants,
satyrs, and other sorts of monsters or grotesque objects, just as it
suited them, and according as the ideas occurred to them so the
works were put into operation.

§ 28. German Work (the Gothic Style).

We come at last to another sort of work called German, which both


in ornament and in proportion is very different from the ancient and
the modern. Nor is it adopted now by the best architects but is
avoided by them as monstrous and barbarous, and lacking
everything that can be called order. Nay it should rather be called
confusion and disorder. In their buildings, which are so numerous
that they sickened the world, doorways are ornamented with
columns which are slender and twisted like a screw, and cannot have
the strength to sustain a weight, however light it may be. Also on all
the façades, and wherever else there is enrichment, they built a
malediction of little niches one above the other, with no end of
pinnacles and points and leaves, so that, not to speak of the whole
erection seeming insecure, it appears impossible that the parts
should not topple over at any moment. Indeed they have more the
appearance of being made of paper than of stone or marble. In these
works they made endless projections and breaks and corbellings and
flourishes that throw their works all out of proportion; and often,
with one thing being put above another, they reach such a height that
the top of a door touches the roof. This manner was the invention of
the Goths, for, after they had ruined the ancient buildings, and killed
the architects in the wars, those who were left constructed the
buildings in this style.[131] They turned the arches with pointed
segments, and filled all Italy with these abominations of buildings, so
in order not to have any more of them their style has been totally
abandoned.
May God protect every country from such ideas and style of
buildings! They are such deformities in comparison with the beauty
of our buildings that they are not worthy that I should talk more
about them, and therefore let us pass on to speak of the vaults.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookfinal.com

You might also like