100% found this document useful (2 votes)
8 views

Building React Apps with Server Side Rendering Use React Redux and Next to Build Full Server Side Rendering Applications Thakkar Mohit pdf download

The document is a guide on building React applications with server-side rendering using React, Redux, and Next.js. It covers essential topics such as JavaScript fundamentals, React components, server-side rendering, unit testing with Jest, and deployment using Docker. The book aims to equip readers with the skills needed to create and deploy fully functional server-side rendered applications.

Uploaded by

drilltegene8
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
8 views

Building React Apps with Server Side Rendering Use React Redux and Next to Build Full Server Side Rendering Applications Thakkar Mohit pdf download

The document is a guide on building React applications with server-side rendering using React, Redux, and Next.js. It covers essential topics such as JavaScript fundamentals, React components, server-side rendering, unit testing with Jest, and deployment using Docker. The book aims to equip readers with the skills needed to create and deploy fully functional server-side rendered applications.

Uploaded by

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

Building React Apps with Server Side Rendering

Use React Redux and Next to Build Full Server


Side Rendering Applications Thakkar Mohit
download
https://textbookfull.com/product/building-react-apps-with-server-
side-rendering-use-react-redux-and-next-to-build-full-server-
side-rendering-applications-thakkar-mohit-2/

Download more ebook from https://textbookfull.com


We believe these products will be a great fit for you. Click
the link to download now, or visit textbookfull.com
to discover even more!

Building React Apps with Server Side Rendering Use


React Redux and Next to Build Full Server Side
Rendering Applications Thakkar Mohit

https://textbookfull.com/product/building-react-apps-with-server-
side-rendering-use-react-redux-and-next-to-build-full-server-
side-rendering-applications-thakkar-mohit-2/

Exploring Blazor: Creating Hosted, Server-side, and


Client-side Applications with C# Taurius Litvinavicius

https://textbookfull.com/product/exploring-blazor-creating-
hosted-server-side-and-client-side-applications-with-c-taurius-
litvinavicius/

Programming Kotlin Applications Building Mobile and


Server Side Applications with Kotlin 1st Edition Brett
Mclaughlin

https://textbookfull.com/product/programming-kotlin-applications-
building-mobile-and-server-side-applications-with-kotlin-1st-
edition-brett-mclaughlin/

React Quickly: Painless web apps with React, JSX,


Redux, and GraphQL 1st Edition Azat Mardan

https://textbookfull.com/product/react-quickly-painless-web-apps-
with-react-jsx-redux-and-graphql-1st-edition-azat-mardan/
Server Side Swift with Vapor Building Web APIs and Web
Apps in Swift 3rd Edition Raywenderlich.Com Tutorial
Team

https://textbookfull.com/product/server-side-swift-with-vapor-
building-web-apis-and-web-apps-in-swift-3rd-edition-
raywenderlich-com-tutorial-team/

Server Side Swift Paul Hudson

https://textbookfull.com/product/server-side-swift-paul-hudson/

Learning React A Hands On Guide to Building Web


Applications Using React and Redux 2nd Edition Kirupa
Chinnathambi

https://textbookfull.com/product/learning-react-a-hands-on-guide-
to-building-web-applications-using-react-and-redux-2nd-edition-
kirupa-chinnathambi/

Practical React Native: Build Two Full Projects and One


Full Game using React Native 1st Edition Frank Zammetti

https://textbookfull.com/product/practical-react-native-build-
two-full-projects-and-one-full-game-using-react-native-1st-
edition-frank-zammetti/

Node js Design Patterns Master best practices to build


modular and scalable server side web applications 2nd
Edition Casciaro

https://textbookfull.com/product/node-js-design-patterns-master-
best-practices-to-build-modular-and-scalable-server-side-web-
applications-2nd-edition-casciaro/
Mohit Thakkar

Building React Apps with Server-Side


Rendering
Use React, Redux, and Next to Build Full Server-Side
Rendering Applications
Mohit Thakkar
Vadodara, Gujarat, India

Any source code or other supplementary material referenced by the


author in this book is available to readers on GitHub via the book’s
product page, located at www.​apress.​com/​9781484258682 . For more
detailed information, please visit http://​www.​apress.​com/​source-code
.

ISBN 978-1-4842-5868-2 e-ISBN 978-1-4842-5869-9


https://doi.org/10.1007/978-1-4842-5869-9

© Mohit Thakkar 2020

This work is subject to copyright. All rights are reserved by the


Publisher, whether the whole or part of the material is concerned,
specifically the rights of translation, reprinting, reuse of illustrations,
recitation, broadcasting, reproduction on microfilms or in any other
physical way, and transmission or information storage and retrieval,
electronic adaptation, computer software, or by similar or dissimilar
methodology now known or hereafter developed.

Trademarked names, logos, and images may appear in this book. Rather
than use a trademark symbol with every occurrence of a trademarked
name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no
intention of infringement of the trademark. The use in this publication
of trade names, trademarks, service marks, and similar terms, even if
they are not identified as such, is not to be taken as an expression of
opinion as to whether or not they are subject to proprietary rights.

While the advice and information in this book are believed to be true
and accurate at the date of publication, neither the authors nor the
editors nor the publisher can accept any legal responsibility for any
errors or omissions that may be made. The publisher makes no
warranty, express or implied, with respect to the material contained
herein.

Distributed to the book trade worldwide by Springer Science+Business


Media New York, 1 New York Plaza, New York, NY 10004. Phone 1-800-
SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com,
or visit www.springeronline.com. Apress Media, LLC is a California LLC
and the sole member (owner) is Springer Science + Business Media
Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware
corporation.
Dedicated to Richard Matthew Stallman, the man who started the free
software movement in order to give software users the freedom to use the
software, to study and modify the software, and to redistribute copies of it
with or without modification. His work on the GNU project is highly
appreciated by the open source community.
Introduction
With the popularity of frameworks such as Node, React, and Angular,
web developers tend to render everything on the client-side, but there
are several disadvantages to this approach. To protect sensitive
information and optimize response times, developers might want to
add server-side rendering to their applications. This book
demonstrates how a React application can be rendered on the server-
side using frameworks such as Next and Redux.
The book starts with the basic introduction to JavaScript, followed
by the introduction to React. Once the reader is aware of both these
concepts, the Next framework is introduced. The reader will then learn
how to integrate Next to a React application in order to render content
on the server-side. The reader will also learn about state management
using Redux, unit testing using Jest, and deployment using Docker. At
the end of this book, the reader will have all the knowledge necessary
to build and deploy a fully server-side rendered application with scripts
for unit testing.
To learn more, start reading right away.
Acknowledgments
The completion of this book could not have been possible without the
contribution of numerous people whose names may not all be cited.
Their contributions are sincerely appreciated and acknowledged.
However, I would like to take this opportunity to express my gratitude
particularly to the following:
Louise Corrigan , Senior Editor at Apress, andJames Markham ,
Development Editor at Apress, who saw potential in the idea behind the
book. They helped kick-start the book with their intuitive suggestions
and made sure that the content quality of the book remains
uncompromised.
Alexander Nnakwue , Technical Reviewer of the book, who made
sure that the practical aspects of the book are up to the mark. His
insightful comments have been of great help in the refinement of the
book.
Nancy Chen , Coordinating Editor at Apress, who made sure that
the process from penning to publishing the book remains smooth and
hassle-free.
Family, friends, and mentors , who have always been supportive of
my aspirations and have guided me throughout my journey.
You , who wish to refine your skills by reading this book so that you
can make a difference in the lives of those around you. You encourage
me to contribute toward collaborative education.
Thank you!
Table of Contents
Chapter 1:​JavaScript Prerequisites
Introduction to JavaScript
Setting Up the Environment
Constants and Variable Declaration
Rest Parameter
Destructuring and Spread Syntax
Control Loops
for
forEach
while
do.​.​.​while
Type Conversion
Operators
Arithmetic Operators
Comparison Operators
Assignment Operators
Logical Operators
Ternary Operator
Functions
Closures
Arrays
Classes and Modules
Creating a Local Server
DOM Modification
Error Handling
HTTP Requests
Promises
Summary
Chapter 2:​Introducing React.​js
Setting Up the Environment
Installing Node.​js
Installing React
Basic Concepts of React
Single-Page Applications
Immutability
Purity
Composition
Creating Your First React Component
Creating Elements Using JavaScript
Creating Elements Using JSX
Function vs.​Class Component
Passing Props
Stateless and Stateful React Components
Working with the State Object
React Lifecycle
Mounting
Updating
Unmounting
Hooks
State Hook
Effect Hook
Custom Hooks
Working with Data
AJAX Calls
Styling React Components
CSS in React
SASS and SCSS in React
Babel and Webpack
Summary
Chapter 3:​Next.​js
Introduction to Next.​js
Features of Next.​js
Getting Started
Routing in Next.​js
Dynamic Pages
Adding Multimedia Content Using CSS
Getting Data from Remote Server
Creating Interactive App Using Next.​js
Using Redux with Next.​js
Store
Actions
Reducers
Using GraphQL with Next.​js
Summary
Chapter 4:​Adding Server-Side Rendering to Your React
Application
Importance of Server-Side Rendering
Building a Simple React App
Creating Functional React Component
Passing Props to Functional React Component
Converting Functional Component to Class Component
Using Next.​js for Server-Side Rendering
Adding CSS to Next.​js
Integrating Bootstrap to Your App
Summary
Chapter 5:​Unit Testing Using Jest
Setting Up Jest
Writing Your First Test Using Jest
Matchers
Common Matchers
Truth Matchers
Comparison Matchers
String Matcher
Matcher for Iterables
Exception Matcher
Testing a React Component Using Jest and Enzyme
Summary
Chapter 6:​Deploying Your App to a Server
Deployment Process
Setting Up Environment Variables
Introduction to Docker
Creating a Docker Container for Your App
Hosting the Container
Summary
Index
About the Author
Mohit Thakkar
is a software engineer with a
multinational company. He has a
bachelor’s degree in computer
engineering and is the author of several
independently published titles,
includingArtificial Intelligence ,Beginning
Machine Learning in iOS ,Data Mining &
Business Intelligence ,iOS Programming ,
andMobile Computing & Wireless
Communication . He has also published a
research paper titled “Remote Health
Monitoring using Implantable Probes to
Prevent Untimely Death of Animals” in
theInternational Journal of Advanced
Research in Management, Architecture,
Technology and Engineering .
About the Technical Reviewer
Alexander Chinedu Nnakwue
has a background in mechanical
engineering from the University of
Ibadan, Nigeria, and has been a front-end
developer for over three years working
on both web and mobile technologies. He
also has experience as a technical author,
writer, and reviewer. He enjoys
programming for the Web, and
occasionally, you can also find him
playing soccer. He was born in Benin City
and is currently based in Lagos, Nigeria.
© Mohit Thakkar 2020
M. Thakkar, Building React Apps with Server-Side Rendering
https://doi.org/10.1007/978-1-4842-5869-9_1

1. JavaScript Prerequisites
Mohit Thakkar1
(1) Vadodara, Gujarat, India

This chapter provides insight on JavaScript fundamentals that are


necessary in order to start working with React. The purpose of this
chapter is to introduce you to the basic programming paradigm
followed in JavaScript so that you can better understand React when it
is introduced in the following chapter.
Even if you are new to JavaScript, you need not worry as this
chapter shall provide you with all the knowledge you need to get
started. You will begin with learning simpler concepts such as
constants, variables, and control loops and will go all the way learning
sophisticated topics such as rest parameters, spread syntax, HTTP
requests, and promises. By the end of this chapter, you will have a
thorough understanding of the language and will be able to start
building web applications with JavaScript.

Introduction to JavaScript
JavaScript is one of the most popular languages for web development,
and it is essential to learn this language in order to create applications
that run on web browsers. Apart from web applications, JavaScript can
also be used to create desktop, mobile, as well as server-side
applications using various frameworks like Meteor, React Native, and
Node.js. However, we will focus on web applications for the scope of
this chapter.
JavaScript was created by Brendan Eich in the year 1995 and was
standardized by ECMA (European Computer Manufacturers
Association) in 1997. As a result, JavaScript is also known as
ECMAScript (ES) . As the web browsers developed over time, so did
JavaScript with the release of ES3 in 1999, ES5 in 2009, and ES6 in
2015. After ES6, there have been minor updates to JavaScript every
year, but ES6 is by far the latest major release.
Let us now set up our development environment so that we can
begin with practical examples on JavaScript programming.

Setting Up the Environment


In order to start programming with JavaScript, I’ll be using the Visual
Studio Code editor which can be downloaded from
https://code.visualstudio.com/download. However, you
can use any editor of your choice.
Once the editor is up and running, we will create our starter
workspace with index.html file. This file will contain our page template
and a reference to our JavaScript file (index.js) which will reside in
scripts folder. We will use <script> tag to link our JavaScript file with
our HTML template. If you want to add styling to your page template,
you can also add a css file (style.css) under the css folder and add a
reference to it in index.html file using <Link> tag. Your folder structure
should look similar to that shown in Figure 1-1.
Figure 1-1 Folder Structure for Starter Workspace
Talking about individual files, index.html should contain the
following code:

<html>
<head>
<title>intro-to-js</title>
<link rel="stylesheet" type="text/css"
href="css/style.css"></script>
</head>
<body>
<h1>Introduction to JavaScript</h1>
<hr/>
<div id="ResultContainer"></div>
<script type="text/javascript"
src="scripts/index.js"></script>
</body>
</html>

Here, we have added reference to our JavaScript file (index.js) and


css file (style.css). Other than that, the template contains a page header
and a section that we will manipulate using JavaScript code. Let us now
check if the reference to JavaScript file is working. To do so, add the
following code to index.js file:

var ResultContainer =
document.getElementById("ResultContainer");

ResultContainer.innerHTML = "Setting up the


environment!";

Note that we have used JavaScript’s getElementById() method to


fetch a section from the template and then altered its text by setting the
innerHTML property. You can also use getElementsByClassName()
method and getElementsByTagName() method in order to access
elements by class name and tag name. Since we already set the ID
property of the <div> element in our HTML template, we used
getElementById() method to fetch the section. We initially stored a
reference to this section in a variable and then accessed its property
using the variable. This is particularly useful when we have multiple
properties to alter. You might not want to go and search for the section
every time you want to modify a property. Hence, it is always a good
programming practice to store references in variables if you are going
to need it multiple times.
You can add the following code to the css file (style.css) in order to
apply styling to the HTML template:

body{
margin-top:20px;
margin-left:20px;
}

h1{
font-size:50px;
}

#ResultContainer{
margin-top:30px;
padding:10px;
width:450px;
height:200px;
border:1px solid black;
font-size:30px;
}

Now let us run our project and see the output. Visual Studio Code
does not have a built-in method to run HTML files in browser. Hence,
we will have to do some configurations to run our project. Check the
documentation for the editor that you are using to find help on launch
configurations. If you are using Visual Studio Code, the following steps
should help you get started:
1. Press Ctrl+Shift+P to open the Command Palette.

2. Type “config” and select the “Tasks: Configure Task” command to


open tasks.json.
3. If tasks.json file does not exist, the editor will ask you to create one
with default template. Go ahead with “others” template.

4. Replace the tasks.json file content with following code:

{
"version": "2.0.0",
"command": "Chrome",
"windows": {
"command": "C:\\Program Files
(x86)\\Google\\Chrome\\Application\\chrome.exe"
},
"args": ["${file}"],
"group": {
"kind": "build",
"isDefault": true
}
}

The preceding process is shown graphically in Figure 1-2. Note that


the figure shows the code that is generated by default. We will need to
change it to the abovementioned code to configure the launch setting
for our application.
Figure 1-2 Launch Configuration
To test the configuration, open index.html file and press
Ctrl+Shift+B. The file should open in Chrome, and you should see the
output similar to that shown in Figure 1-3.

Figure 1-3 Output for Starter Project


Now that our development environment is up and running, let’s
explore some basic JavaScript concepts.

Constants and Variable Declaration


Constants are identifiers whose value remains same throughout the
scope of the program. On the other hand, variables are identifiers
whose value can be changed at any time. One thing to note is that you
can declare a variable and initialize it later in the code, but in case of
constants, you have to assign a value during the declaration itself. A
constant can be declared by using “const” keyword. For example:

const weightInKilos = 100;

Variables in JavaScript can be declared using either “let” or “var”


keyword. While both of these keywords are used for variable
declaration, there is a significant difference in scope of variables
declared using each of these keywords. Variables declared with “var”
keyword are accessible throughout the program, whereas variables
declared using “let” keyword are only available in the block in which
they are declared. Let us understand this with an example:

...
if(true){
let letVariable = "Variable using let";
}
ResultContainer.innerHTML = letVariable;
If you try to execute the preceding piece of code, you might get an
error in the console stating that “letVariable is not defined”. This is
because you are trying to access letVariable outside its scope. Change
the code to the following and you should see the output similar to
Figure 1-4:

...
if(true){
var varVariable = "Variable using var";
}
ResultContainer.innerHTML = varVariable;

Figure 1-4 Variable Declaration Using let and var


Another difference between let and var is that if you try to access a
“let” variable before its declaration, the system will throw an undefined
error, but in case of a “var” variable, the system will not throw any
error. For example, consider the piece of code in Figure 1-5. The last
two lines might give you error for accessing a variable that’s never
declared. However, the first two lines will give you no errors. We would
always want the system to throw us an error when we are trying to
access a variable before its declaration. Thus, it is always a good
practice to use the “let” keyword instead of “var” keyword to declare
variables.

Figure 1-5 let vs. var

Rest Parameter
Rest parameter is a feature of JavaScript that was introduced in ES6. It
lets us handle multiple function input parameters as an array. It is
particularly helpful in scenarios where the number of input parameters
to a function is indefinite.

Note ES6 is the sixth version of ECMAScript and was created to


standardize JavaScript. Since it was published in 2015, it is also
known as ECMAScript 2015.

Let us understand this with the help of the following example:

...
function sum(...inputs) {
var result = 0;
for(let i of inputs){
result += i;
}
return result;
}
ResultContainer.innerHTML = sum(5, 10, 5, 5);
This should give you an output of “25” on your HTML template. Now
let us understand what is happening here. When we declare a function
with rest parameter and invoke it, JavaScript automatically takes in all
the arguments we pass to the function and clubs it into an array. The
function can then iterate through the array and perform operations on
all the input elements supplied. Rest parameter can also be used with
regular parameters. However, rest parameter should always be the last
argument so that JavaScript can collect all the remaining elements and
club it into an array. Consider the following example:

...
function sum(input1, input2, ...remainingInputs) {
var result = input1 + input2;
for(let i of remainingInputs){
result += i;
}
return result;
}
ResultContainer.innerHTML = sum(5, 10, 5, 5);

The preceding piece of code will also give you an output of “25” on
your HTML template. The only difference here is that only the last two
input parameters will be considered as rest parameters, whereas the
first two are regular parameters. One of the major benefits of rest
parameter is that array operations such as filter, sort, pop, push,
reverse, and so on can easily be performed on input parameters.

Destructuring and Spread Syntax


Destructuring is another feature of JavaScript that was introduced in
ES6 and is exactly opposite of rest parameter. While rest parameter is
about assigning multiple values to a single array, destructuring is about
fetching values from a single array or an object and assigning it to
multiple variables. Let us understand this with the help of an example:

...
let fruits = ['Apple', 'Watermelon', 'Grapes'];
let [fruit1, fruit2, fruit3] = fruits;

ResultContainer.innerHTML = fruit2;
The preceding piece of code will give you “Watermelon” as output.
This is because when we use destructuring syntax (variables in square
brackets separated by commas on left and an array or object on right),
JavaScript automatically extracts values from the array on the right-
hand side and starts assigning them to the variables on the left-hand
side. Note that the values are assigned from left to right. So, for
instance, if there are two variables on the left-hand side and four array
elements on the right-hand side, then the first two values from the
array will be assigned to the variables and the last two values will be
left out. On the contrary, if there are four variables on the left-hand side
and just two array elements on the right-hand side, the values will be
assigned to the first two variables and the last two variables will be
undefined.
We can also skip some array elements while assigning it to
variables. To do so, add an extra comma separator on the left-hand side.
Consider the following example:

...
let fruits = ['Apple', 'Watermelon', 'Grapes'];
let [fruit1, , fruit2] = fruits;

ResultContainer.innerHTML = fruit2;

This time, the output that will be displayed on your HTML template
will be “Grapes”. This is because when JavaScript tries to find the
second variable for assigning second array element, it finds a null entry
because of the comma separator and skips that particular array
element. Another interesting thing you can do with destructuring is
that you can assign first few array elements to separate variables and
assign remaining array elements to a single variable using the rest
parameter syntax. Have a look at the following example to get a better
understanding:

...
let fruits = ['Apple', 'Watermelon', 'Grapes',
'Guava'];
let [fruit1, ...OtherFruits] = fruits;
ResultContainer.innerHTML = OtherFruits;
The preceding piece of code will give you “Watermelon, Grapes,
Guava” as output because the rest parameter syntax will assign all the
remaining array elements to the “OtherFruits” variable.
Objects can be destructured in a similar way to arrays with the only
exception being the use of curly brackets instead of square brackets on
the left-hand side to specify variables. Consider the following example
of destructuring object:

...
let Fruits = {Fruit1: 'Apple', Fruit2:
'Watermelon'};
let {Fruit1, Fruit2} = Fruits;

ResultContainer.innerHTML = Fruit1;

The preceding piece of code will give you “Apple” as output. Let us
now try to use destructuring in functions. We will try to pass an array
as input parameter and destructure it in the function definition. Please
look at the following piece of code:

...
function sum(a, b, c){
return a+b+c;
}

let input = [5,9,6];


ResultContainer.innerHTML = sum(...input);
The output of the preceding code should be “20”. What we are doing
here is exactly opposite of rest parameter. We are creating a single array
of input elements and passing it directly into a function that takes in
three different parameters. The function declaration will be similar to
that of a regular function. However, notice the syntax that we are using
while calling the function (the three dots before the parameter name).
This is known as spread syntax and this will do all the work for us. It is
identical to the syntax of rest parameter. However, if you use it while
calling the function, it will work in an opposite manner. So, instead of
collecting input parameters and clubbing it into an array, it will
destructure the array of input parameters and assign the values to the
variables mentioned in the function declaration. You can also use the
rest parameter and spread syntax at the same time. The manner in
which it will behave will depend on the context. Let us now look at
control loops.

Control Loops
JavaScript provides multiple ways to iterate through loops. Let us look
at each one of them with examples.

for
The for loop takes in three parameters: the first parameter is for the
initialization of the control variable, the second one is the condition
that provides entry to the loop if true, and the last one is increment or
decrement parameter that will modify the value of control variable in
each loop. These three parameters are followed by the body of the loop:

...
for(let i=0;i<8;i++){
if(i==1){
continue;
}
console.log("i: " + i);
if(i==4){
break;
}
}
We can use break and continue operators with all kinds of
JavaScript loops. The continue operator is used to skip the remaining
statements from the body of the loop and skip to the next iteration,
whereas the break operator is used to terminate all the remaining
iterations of the loop.
Notice the preceding piece of code and its output in Figure 1-6. The
loop is conditioned to run for eight iterations and print the number of
iteration in each execution. However, for the second iteration, the if
condition before the print statement in the body of the loop will
evaluate to true and the execution of continue operator will make the
loop jump to the next iteration. Hence, we do not see the value “1” in
the output. Similarly, for the fifth iteration, the if condition after the
print statement will evaluate to true and the execution of break
operator will terminate the remaining iterations of the loop. Thus, we
do not see remaining values after “4” printed in the output.

Figure 1-6 for Loop in JavaScript

forEach
forEach loop is called on an array or a list and executes a function for
each array element. The function takes in three parameters: the current
value (fruit), the index of the current value (index), and the array object
that the current value belongs to. The second and third parameters are
optional, whereas the first parameter is mandatory. One of the major
benefits of using this control loop is that the function would not be
executed for empty array elements, which results in better response
time for the end application:

...
let fruits = ['Apple','Grapes','Watermelon'];
fruits.forEach((fruit, index) => {
console.log(index + ': ' + fruit);
})

while
while loop is an entry-controlled loop similar to for loop, which means
that the condition that validates the entry to the loop is checked during
the beginning of the iteration. However, unlike for loop, you don’t have
to initialize or modify the control variable along with the condition. The
initialization is done before the beginning of the loop and its value is
modified in the loop body:

...
let fruits = ['Apple', 'Grapes', 'Watermelon'];
let i = 0;
while (i < fruits.length) {
console.log(i + ': ' + fruits[i]);
i++;
}

do...while
do...while loop is a variation of the while loop which is exit-controlled,
which means that the condition that validates the entry to the loop is
checked after the completion of an iteration. If true, the loop will
execute the next iteration:

...
let fruits = ['Apple', 'Grapes', 'Watermelon'];
Another Random Document on
Scribd Without Any Related Topics
But enough of this gossip: the reader of the Cortegiano, and its
author's charming letters, will find there many more attractive and
not less veracious touches of the Montefeltrian court, where learning
and accomplishment were often called upon to give dignity and
grace to social pastimes. Thus, the Duchess is represented as
singing to her lute those verses from the fourth Æneid, in which, at
the moment of self-immolation, Dido apostrophised the garments
forgotten by her faithless lover when he fled from her charms, until,
Orpheus-like, she had wiled the savage animals from their lairs, and
set the stones in sympathetic movement. At her court there were no
lack of pens to clothe in verse the passing fancies of the hour, and
adapt them to the musical or melodramatic tastes which gave a tone
of refinement to its amusements. Thus, for the carnival of 1506,
Castiglione and his messmate Cesare Gonzaga composed the
pastoral eclogue of Tirsis, which was acted by them before the
court, with choruses and a brilliant moresque dance. The personages
of the dialogue are Iola (Castiglione) and Dameta (Gonzaga), who
describe to Tirsi, a stranger shepherd, the ducal circle of Urbino,
with the Duchess at its head as goddess of the river Metauro. The
Moresca, so named from its supposed Moorish origin, was perhaps
borrowed from the ancient Pyrrhic dance, and consisted in a sort of
mock fight, performed to the sound of music with measured tread,
and blunted poignards. Next spring a somewhat similar pastoral,
from the pen of Bembo, was recited by him and Ottaviano Fregoso
to the same audience.
Such and such-like were the favourite court diversions of Urbino.
Their stately conceits and solemn pedantry suited the spirit of that
classic age and the genius of a pomp-loving people; but it would be
scarcely fair to regard them as fully embodying the tone of manners
prevalent in the palace of Guidobaldo. In it were harmoniously
mingled the opposite qualities which then predominated at the
various Italian courts. Scholastic pretensions, still esteemed in many
of them, here thawed before the easier address of the new school.
Those abstruse studies which the Medici had brought into vogue
were eclipsed by a galaxy of brilliant wits. Even the ruthless bearing
of the old condottieri princes mellowed under the charm of female
tact, while the sensual splendour indulged by recent pontiffs was
chastened by the exemplary demeanour of the ducal pair.
Our appreciation of this picture would, however, scarcely be correct
or complete, did we not bear in mind the inner life of contemporary
sovereigns. We need not dwell on the contrasts afforded in other
Peninsular capitals, for these were rather of degree than character,
and would only show us the prevalence here of a gentler courtesy
and more pervading refinement. But we may fairly compare the
palace-pastimes of Urbino with those held in acceptance by the
princes and peerage of northern states, where deep potations dulled
the senses, or brutalised the temper; where intellect rarely sought a
more refined gratification than the monotonous recital of legendary
adulation; and where wit was monopolised by dwarfs and
professional jesters. In order better to preserve the form and fashion
of this pattern for princes, we shall transfer to our pages, from
Castiglione's groupings, some outlines of its chief ornaments,
beginning with himself.[35]
Raffaele pinx. L. Ceroni
sculp.
COUNT BALDASSARE CASTIGLIONE.
From a picture in the Torlonia Gallery, Rome

From Castiglione, in Lombardy, sprang the ancestry of Count


Baldassare, and among them were numbered not a few names of
note in church and state. His father was no mean soldier, in times
when the captains of Italy bore a European reputation; his mother, a
Gonzaga of the Mantuan house, was descended from the haughty
Farinato degli Uberti, who, when accosted by Dante in The Vision,—

"His heart and forehead there


Erecting, seemed as in high scorn he held
E'en hell."

The Count was born at Casatico, in the Mantuese, on the 6th of


December, 1478.[*36] His education, besides including the various
studies and accomplishments usual to an Italian gentleman of the
fifteenth century, was specially directed to those classical
attainments which entered into the literary pursuits of the age. The
death of his father left him early master of a handsome patrimony,
and he at once embraced that courtier-life for which he was
peculiarly fitted,—a life, which in a land subdivided into petty
sovereignties, constituted the only profession open to civilians of
noble birth and distinguished endowments, and on which his pen
was destined to confer perpetual illustration. After a brief visit to
Milan,[*37] and a short campaign in Naples with his relative the
Marquis Francesco of Mantua, he repaired to Rome in 1503, where,
by discretion and winning address, he quickly gained the new
Pontiff's favour. In Count Castiglione, the penetration of Julius
recognised a fit instrument for promoting his favourite scheme of
securing Urbino to his nephew Francesco Maria della Rovere; and by
attaching him to Guidobaldo, he fixed at that court a friend whose
influence was certain to extend itself, and whose example would
benefit his youthful relation.
The court of Urbino had already been for half a century the brightest
star in the constellation of Italian principalities, and under its
fostering influence were fully developed those fine qualities which
nature and early training had formed in Castiglione. His first essay
was as captain of fifty men-at-arms, with 400 ducats of nominal pay,
besides allowances; and his earliest exploit in this new service was
the reduction of Forlì, in 1504. The finances of Guidobaldo were
necessarily at a low ebb, and it is amusing to find Baldassare's
frequent lamentations to his mother, over the arrears of his pay:
—"Our doings are jolly but inconsiderable, that is, on small means;
we have never yet seen a farthing, but daily and most devoutly look
for some cash." It was not, however, till nearly a year later that he
received twenty-five ducats to account, having often in the interval
asked her aid, representing himself as penniless, and living upon
credit. In 1509,[*38] after returning from his mission to England,
which peculiarly required the graces of a finished cavalier, and of
which some account will be found in II. of the Appendix, he attached
himself to the Duke's immediate person during the brief remainder
of his life, and when it closed, was sent to Gubbio, to maintain the
interests of the succession, in event of any popular outbreak. The
favour which he had enjoyed from Guidobaldo was amply continued
under his nephew, whose fortunes he followed during several years,
sharing his successes in the field, and sustaining him under his
disgrace at the pontifical court. These events must, however, be
here touched with a flying pen, that we may not anticipate details on
which we shall afterwards have to dwell. His reward was a grant of
Novillara, near Pesaro; and when Francesco Maria had exchanged
sovereignty for exile, he returned to the service of his natural lord,
the Marquis of Mantua, whom he long represented at the court of
Leo X. To this Pontiff, Baldassare had nearly become related, by a
marriage with his niece Clarice de' Medici, which was greatly
promoted by Giuliano, during their residence at Urbino. The
negotiation was, however, broken off in January, 1509, by the
intrigues of her aunt, Lucrezia Salviati, who persuaded her uncle, the
Cardinal Giovanni, that, by bestowing her hand upon Filippo Strozzi,
he would strengthen the interest of his family at Florence. The
match having been, according to Italian usage, an interested
arrangement, its dissolution was borne with great philosophy by the
intended bridegroom; who some seven years later married Ippolita,
daughter of Count Guido Torelli, a celebrated condottiere, by
Francesca, daughter of Giovanni Bentivoglio, Lord of Bologna.[*39]
The ceremony was performed at Mantua, and was celebrated with
tournaments and pompous shows, in which the court and people
took a lively interest. But their happy union was of brief duration.
The Countess died four years after, in childbed of a daughter. Her
name has been embalmed in a beautiful Latin ode, wherein her
husband embodied those laments for his absence which he
doubtless had often heard from her lips, expressing all the
tenderness of nuptial love, and adorning a woman's pathos with a
poet's fire. Nothing can be more beautiful than the allusion to her
husband's portrait:—

"Your features portrayed by Raffaele's art


Alone my longings can solace in part:
On them I lavish jests and winning wiles,
As if their words could echo back my smiles;
At times they seem by gestures to respond,
And answer in your wonted accents fond:
Our boy his sire salutes with babbling phrase.
Such are the thoughts deceive my lingering days."

In her epitaph, the Count summed up his wife's character and


endowments, with a doubt whether her beauty or her virtue were
more remarkable; to which her eulogist, Steffano Guazzo, has added
a third grace—her learning. During the first anguish of widowhood
he was supposed to have turned his thoughts to ecclesiastical
orders; but whatever views of that nature he may have entertained
were speedily abandoned; and in 1523 we find him again in
Lombardy, with his gallant company, under the banner of the
Gonzagas.
On the accession of Clement VII., the Marquis of Mantua again sent
him to represent his interests at Rome, where he was not long in
obtaining from the new Pope the same favour which he had enjoyed
under his uncle, Leo X. His diplomatic talents were now
acknowledged as of the first order; and Clement, foreseeing,
perhaps, the impending difficulties of his position with the Emperor,
prevailed upon Castiglione to accept the nomination of nuncio to
Madrid. His courtly qualities were not less agreeable to Charles V.
and the grandees of Spain than they had been in Italy; and in the
romantic project by which the Emperor proposed to decide in single
combat his unquenchable rivalry with Francis I., the Count was
selected as his second,—an honour which his diplomatic functions
prevented his accepting. Even while the troops and name of Charles
were used by Bourbon to inflict upon the Apostolic See the greatest
blow which its capital had suffered since the temporal power of the
Church rose on the ruins of the Roman empire, the Nuncio was
receiving new honours at Madrid, and was only prevented by his
own scruples from obtaining the temporalities of the bishopric of
Avila, one of the richest in Spain. In this most delicate position he
retained the confidence of his master, who seems to have been
satisfied that to no remissness on his part were owing the horrors of
the sack of Rome. But these miserable results of jealousies between
the Pope and the Emperor, which all his tact and influence were
powerless to remove, rendered his position anything but enviable,
and appear to have preyed alike upon mind and body. He sank
under a short illness at Toledo, on the 2nd of February, 1529,[*40]
and was lamented by Charles as "one of the best knights in the
world." A letter of condolence, written to his mother by Clement,
affords ample evidence that the fruitless results of his diplomacy in
Spain had nowise diminished the Pope's confidence in his good
service and attachment to his person.
Alinari
HAIR DRESSING IN THE
FIFTEENTH CENTURY
Detail from the fresco by Pisanello in
S. Anastasia of Verona

In the Cortegiano of Castiglione we are furnished with an elaborate,


and in the main faithful, delineation of the men, the manners, and
the accomplishments which rendered the court of Urbino a model for
his age, and also with an interesting picture of the immediate circle
which Guidobaldo and his estimable Duchess formed around them.
We have drawn upon it amply for this portion of our volumes, but
the notices which it affords of the Duke are of the most vague and
disappointing character. This deficiency would be of little
consequence, did the accounts which the same author has left in a
Latin letter to Henry VIII. do full justice to his early patron. But from
one whose opportunities of collecting ample and authentic
particulars were unusual, the passing allusions to many momentous
incidents are truly unsatisfactory. His details of scholarship and
accomplishments would be more valuable, if divested of an air of
exaggeration which even solemn asseverations of veracity scarcely
remove. With all their faults, these are preferable to the compilation
of Bembo, to which we shall in due time more particularly advert.
Those who wade through its laboured and redundant expletives will
probably come to the conclusion that Castiglione has preserved
whatever they contain worthy of notice.
The Count was a finished gentleman, in an age when that character
included a variety of mental acquirements, as well as many personal
accomplishments. His verses in Latin and Italian breathe a fine spirit
of poetry; his letters merit a distinguished place as models of
correspondence; his diplomatic address was highly approved by the
sovereigns whom he served, as well as by those to whom he was
accredited; he has been complimented as the delight of his
contemporaries, the admiration of posterity.

Giuliano de' Medici was third son of Lorenzo the Magnificent, and was
known in the circle of Urbino by the same appellation. Born in 1478,
he passed at that court several years of his family's exile from
Florence; nor was he ungrateful for the splendid hospitality he there
enjoyed, for, while he lived, his influence with his brother, Leo X.,
averted those designs against the dukedom, which were directed to
his own aggrandisement. After the restoration of the Medici, Leo
confided to him the government of Florence, which he endeavoured
to administer in the spirit of his father, and succeeded in gaining the
good will of the people. But the Pope was not satisfied with the re-
establishment of his race as sovereigns of that republic; and the fine
qualities and vast ideas of Giuliano suggested him as a fit instrument
of further grasping schemes. To realise these, Leo coquetted
between France and Spain, and, like his predecessors, sacrificed the
peace of Italy. The prizes which he successively proposed for
Giuliano, who, by resigning Florence into the hands of his nephew
Lorenzo, the heir-male of his house, was free to accept whatever
sovereignty might be had, were the duchy of Milan, a state in
Eastern Lombardy and Ferrara, or the crown of Naples. In June,
1515, the Pontiff conferred on him the insignia of gonfaloniere and
captain-general of the Church; but he was prevented from active
service by a fever which cut him off in the following March, when
only thirty-eight, not without suspicion of poison at the hands of his
nephew Lorenzo. His name is enshrined in Bembo's prose and
Ariosto's verse, whilst his tomb by Michael Angelo in the Medicean
Chapel, which Rogers, with a quaint but happy antithesis, calls "the
most real and unreal thing which ever came from the chisel," is one
of the glories of art.[*41] Shortly before his death he had married
Filiberta of Savoy, whose nephew, Francis I., created him Duke of
Nemours, and, had his life been prolonged, would probably have
aided him to further aggrandisement.
During his residence at Urbino, from an intrigue with Pacifica
Brandani, a person of high rank or base condition, for both extremes
have been conjectured to account for the mystery, there was born to
him a son, who, after being exposed in the streets in 1511, was sent
to the foundling hospital, and baptized Pasqualino. Removed to
Rome and acknowledged in 1513, the child received an excellent
education; and under the munificent patronage of the Medici
became Cardinal Ippolito, whose tastes were more for arms than
mass-books, and whose handsome features and gallant bearing,
expressive of his splendid character, are preserved to us in the Pitti
Gallery by the gorgeous tints of Titian, alone worthy of such a
subject.
The next personage of this goodly company was Cesare Gonzaga,
descended from a younger branch of the Mantuan house, and
cousin-german of Count Baldassare, whose quarters he shared in
1504, when they returned together from the reduction of Valentino's
strongholds in Romagna, where he had the command of fifty men-
at-arms. We know little of him beyond his having been a knight of
St. John of Jerusalem, and ambassador from Leo X. to Charles V.
[*42] Baldi describes him as not less distinguished by merit than
blood, and Castiglione assigns him a prominent place in the lively
circle whose amusements he depicts. He was no unsuccessful
devotee of the muses: a graceful canzonet by him is preserved in
the Rime Scelte of Atanagi, and he shares the credit of the eclogue
of Tirsis already alluded to, and printed among the works of
Castiglione. Recommended by military talent, as well as by
diplomatic dexterity and business habits, he remained in the service
of Duke Francesco Maria during his early campaigns; and in
September, 1512, after reducing Bologna to obedience of the Pope,
died there of an acute fever in the flower of his age.

The brothers Ottaviano and Federigo Fregoso were of a Genoese


family, who for above a century had distinguished themselves in the
military, naval, and civil service of their country, and had given
several doges to that republic. Their father, Agostino Fregoso, had
married Gentile, natural daughter of Duke Federigo, and the young
men were consequently much brought up at the court of Urbino,
where their sisters Margherita and Costanza were long in attendance
on Duchess Elisabetta. In 1502, Ottaviano accompanied his uncle on
his first return from Venice, and we have seen him then defending S.
Leo during a lengthened siege, sustained with great gallantry and
skill. For that good service he had from the Duke the countship of
Sta. Agatha in the Apennines, afterwards confirmed to him by an
honourable brief of Leo X., and continued to his descendants, with
the title of Vicar, until their extinction in the third generation.
The latter period of Ottaviano's life was actively passed in his native
city. From 1512 his endeavours were directed to abolish the French
domination maintained at that time by aid of the Adorni, long
hereditary rivals of his family. In this he finally succeeded, and next
year was elected doge, the only one, in Litta's opinion, "who
gloriously manifested a desire for the public weal." He held that
dignity during two years of tranquillity to his country, over which the
benign influence of his mild and impartial sway diffused a temporary
calm, long unknown to its factious inhabitants. So obvious were
these beneficial results, that Francis I., on becoming master of
Genoa in 1515, continued to him a delegated authority as its
governor. But, seven years later, the restless Adorni, having adhered
to the Emperor, aided the Marquis of Pescara to carry the city, with
an army of imperialists, who mercilessly sacked it. Ottaviano
remained a prisoner in the enemy's hands, and died soon after. He is
called in the Cortegiano "a man the most singularly magnanimous
and religious of our day, full of goodness, genius, prudence, and
courtesy; a true friend to honour and virtue, and so worthy of praise
that even his enemies are constrained to extend it to him." The
revolution effected by Andrea Doria, in 1528, forcibly closed the
feuds of these rival families, which, during a century and a half, had
outraged public order, and, both being compelled to change their
name, the Fregosi adopted that of Fornaro.

Federigo Fregoso, the younger brother of Ottaviano, born in 1480,


was educated for holy orders under the eye of his maternal uncle
Guidobaldo. In the lettered society of Urbino he perfected himself in
various accomplishments, as well as in a thorough knowledge of the
world, which enabled him afterwards to acquit himself usefully and
creditably in many diversified spheres of action. It was to the great
satisfaction of that court that in April, 1507, Julius II. conferred upon
him the archbishopric of Salerno, a benefice which the opposition of
Ferdinand II., founded on his leaning to French interests, apparently
prevented him from enjoying. His life of literary ease remained
uninterrupted until his brother's elevation as doge of Genoa in 1513,
when he hastened to support him by his counsels and influence.
During the next nine years he alternately commanded the army of
the republic, led her fleet against the Barbary pirates, whom he
annihilated in their own harbours, and represented her as
ambassador at the papal court. The revolution of 1522 compelled
him to fly from his native city, and, taking refuge in France, he
received protection and preferment from Francis I. He returned to
Italy in 1529, and was appointed to the see of Gubbio, where his
piety, and devotion to the spiritual and temporal welfare of his flock,
were equally commendable, and gained him the appellation of father
of the poor and refuge of the distressed. A posthumous imputation
of heretical error cast upon his name had no better foundation than
the accident of his discourse upon prayer happening to be reprinted
along with a work of Luther, which occasioned their being both
consigned to the Index. In 1539 he was made cardinal by Paul III.,
and died at Gubbio two years after. His attainments in philology were
eminent, including a profound knowledge of Hebrew, with the study
of which he is said to have consoled his exile in France. Equal
cultivation might have gained him much fame as a poet, but the
works he has left are chiefly of a doctrinal character, and his
eminence in the literary circle of his day rests more upon the
correspondence of Bembo, Sadoleto, and Cortesio than upon his
own writings.[*43] By the first of these, the sparkle of his measured
wit, the general moderation and suavity of his manners, his gentle
consideration for other men's habits, his personal accomplishments,
and the zeal displayed in his studies, are all spoken of with warm
admiration. The following letter of sympathy, addressed to the
dowager Duchess by that rhetorician is an interesting though
mannered tribute to his long friendship:—
"My most illustrious and worshipful Lady,
"I had somewhat dried the tears elicited by the death
of our very reverend Monseigneur Fregoso, so
suddenly and inopportunely taken from us, when your
Excellency's autograph letters recalled them to my
eyes, and still more abundantly to my heart, on finding
that you condoled with me so sensibly, and with so
much unction. Not only, indeed, has your Ladyship
been bereaved of a rare friend and relative, a most
wise and religious gentleman, but, as you observe, all
Christendom has thus sustained a loss incomparably
great in times so evil and convulsed. Of myself I shall
say little, having already written a few days ago to
your Excellency; and, knowing the affection and
respect mutually existing between you, I appreciate
the weight of your grief from my own. Nor can I doubt
that your Ladyship is aware of my emotion consequent
upon his long kindness towards me, and my respectful
but warm affection for him, sentiments never
interrupted by a single word on either side, from his
early youth and my manly age down to this day. I am
further pained to observe that your Ladyship,
lamenting for long years your Lord's death of happy
memory, and now that of the Cardinal, entertains an
impression your life will be short. This is no fruit of
that good sense I have ever noticed in you, and which
the Cardinal himself inculcated; for the more your
Ladyship is left alone to promote the welfare and
advantage of the tender plants by your side, you
should be more anxious to live on; for, while life is
given you, you may benefit their souls by prayers and
good deeds, as well as promote the interests of many
who look to your pious spirit for the prosperity of their
lot. Let not, therefore, your Ladyship speak thus, but
bless (si conforti) the Heavenly King that he has so
willed it, and conform yourself to his infallible will and
judgment. As to your observation that I am left to you,
in place of this good gentleman, as a protector, father,
and brother, be assured that the day shall never come
when it will not be my desire to dispose of myself in all
respects according to your Excellency's pleasure,
yielding therein not even to your [late] most reverend
brother. Your Ladyship will consider me as truly, really,
and justly your own, to use and dispose of me
unreservedly; and for this end I give, grant, and give
over to you full leave and power, not to be reclaimed
by any change of fortune so long as life remains to
me. In return I shall now pray you to attend to your
health, and not only to live on, but live as happily as
you can, thus avenging yourself of fate, which has
done so much to vex you.... From Rome, the 2nd of
August, 1541."

Pietro Bembo[*44] was born at Venice in 1470, and had the first
rudiments of education at Florence, whither his father Bernardo was
sent as ambassador from the Signory. Having learned Greek at
Messina under Constantin Lascaris, and studied philosophy at Padua
and Ferrara, he devoted himself to literary pursuits. At the court of
the d'Este princes, where he was introduced by his father then
resident as envoy from Venice, he met with the consideration due to
his acquirements, and found a brilliant society, including Sadoleto,
the Strozzi, and Tibaldeo. There he was residing when the arrival of
Lucrezia Borgia threatened to establish for it a very different
character; but the dissolute beauty seems to have left in the Vatican
her abandoned tastes, and adopting those of her new sovereignty
she became distinguished as a patroness of letters. The intimacy
which sprang up between this princess and Bembo has given rise to
some controversy as to the purity of its platonism, a discussion into
which we need not enter. The life of the lady, the writings of the
Abbé, and the morals of their time combine to justify suspicion,
where proofs can hardly be looked for.[*45]
"But if their solemn love were crime,
Pity the beauty and the sage,—
Their crime was in their darkened age!"

Anon. des. L. Ceroni


sculp.
CARDINAL BEMBO
From a drawing once in the possession of
Cavaliere Agricola in Rome

Their correspondence lasted from 1503 to 1516, and many of his


letters are published.[*46] The prevailing tone of these is rhetorical
rather than passionate, and is quite as complimentary to her virtues
as to her beauty. The Ambrosian Library at Milan possesses nine
autograph epistles in Italian and Latin from Lucrezia, addressed "to
my dearest M. Pietro Bembo," with the dates supplied in his hand. A
tress of fair auburn hair, originally tied up with them, and doubtless
that of the Princess, is now shown in the adjoining museum. That
her tastes and accomplishments were not unworthy of such a
friendship appears from many dedications of works to her while
Duchess of Ferrara, including the Asolani of her admirer.
In 1505 Bembo repaired to Urbino, and sojourned chiefly at that
court during the next six years, where his varied attainments were
highly prized, and where his philological pedantry was probably
regarded as ornamental. Besides enjoying the converse of many
congenial spirits, he there formed a friendship with Giuliano de'
Medici, to which he owed many subsequent honours. Accompanying
him to Rome in 1512, he was recommended by him to his brother,
the Cardinal, whose first act on being chosen Pope in the following
year, was to name Bembo his secretary, jointly with his friend
Sadoleto. For this situation he was in many respects well fitted, by
the happy union of great learning with an extensive knowledge of
men and manners, which his residence at Ferrara and Urbino had
not failed to impart. The laxity of his morals, and the paganism of
his ideas, were unfortunately no disqualifications under Leo X. He
continued to earn his master's confidence in the discharge of his
regular duties, as well as in occasional diplomatic missions, but, as
Roscoe truly observes, his success as a negotiator did not equal his
ability in official correspondence. The pensions and benefices which
rewarded his services enriched him for life, and even before that
Pontiff's death he sought at Padua an elegant literary retirement,
refusing from Clement VII., and from the Signory of Venice, all offers
of public employment. He surrounded himself with a most select
library, including many invaluable manuscripts, and a precious
collection of medals and other antiquities, which, with the society of
the learned whom he attracted to his board, gave to his house a
wide celebrity. It was not regarded as at all degraded by the
presence of an avowed mistress at its head, with whom he openly
lived for many years, and had several children; and neither this
scandal, nor the gross indecency of some of his writings, prevented
Paul III. from conferring upon him a scarlet hat in 1539. He is said
to have accepted this dignity unwillingly, but having done so, he had
the good sense at all events to "cleanse the outside of the cup and
platter." His mistress was now dead; he laid aside poetry, literature,
and pagan idioms, and, devoting himself to theological studies, at
which he had formerly sneered in the habit of an abbé, he entered
holy orders at the mature age of sixty-nine. In 1541 he succeeded
Fregoso, his early companion at Urbino, in the bishopric of Gubbio,
to which was added that of Bergamo. How little these preferments
contributed to his comfort appears from a letter to Veronica
Gambara in December, 1543. "Often," he there says, "do I desire to
be the unfettered Bembo of other days, rather than as I now am.
But what better can one make of it? Man's existence, abounding
more in crosses than in gratifying incidents, will have it so; and wiser
he who least desponds and best puts up to necessity, than one that
less conforms to it. Yet I own myself unable to do this amid these
privations, and exiled in a manner from myself. For verily I am
neither at Venice nor Padua, as your Ladyship supposes, but at my
church of Gubbio, a very wild place to say the truth, and offering few
conveniences." He died at Rome six years after, in his seventy-
seventh year, and was buried in the church of the Minerva, between
his patrons Leo X. and Clement VII., where a modest flag-stone is all
the memorial that his natural son and heir, Torquato, bestowed on
one of the most famous men of his age.

At the town of Bibbiena, in the upper Val d'Arno, there were born
about 1470, of humble parentage, two brothers, whose business
talents procured them remarkable advancement. The elder, Pietro
Dovizi, became a secretary of Lorenzo de' Medici, into whose family
he introduced his brother Bernardo. There this youth gained for
himself so good a reputation, that he was allowed to share the
instructions bestowed upon his patron's younger son Giovanni. A
close intimacy gradually sprang up between these fellow students,
which the similarity of their talents, their tastes, and their pursuits
ripened into lasting friendship. Identifying himself with the Medici,
he followed their fortunes into exile, and attended Giuliano to
Urbino, where he was received with the welcome there extended to
all who, like him, combined the scholar and the gentleman. But this
hospitality met with a very different return from these two guests. Of
Giuliano's generous forbearance to second the evil designs of his
brother, the Pope, against the state which had sheltered him, we
have lately spoken. When we come to narrate the usurpation of the
duchy by the Medici in 1516-17, we shall find in command of their
invading army

"That courteous Sir, who honours and adorns


Bibbiena, spreading far and high its fame,"

and who had adopted that town as a substitute for his own
undistinguished patronymic. This ingratitude was the more odious if,
as it was probable, he owed to Guidobaldo, or his nephew, the
favour of Julius II., who first brought him forward in the public
service.
At that Pontiff's death he was acting as secretary to his early friend,
the Cardinal de' Medici, and in that capacity was admitted to the
conclave. The intrigues which there effected his patron's election
have given rise to various anecdotes and controversies, which we
pass by with the single remark that, by all accounts, the address of
Dovizi was not unimportant to the success of Leo X. In return, he
was included in the first distribution of scarlet hats as Cardinal
Bibbiena. In this enlarged sphere his talents and tastes had full room
for exercise. He was selected for various important diplomatic trusts,
besides filling the offices of treasurer and legate in the war of
Urbino. With his now ample means, his patronage of letters and arts
had ample scope, and he was regarded as the Maecenas of a court
rivalling that of Augustus. Raffaele enjoyed his particular regard,
which he would willingly have proved by bestowing on him the hand
of his niece.
His ambition is alleged to have exceeded even the rise of his
fortunes, and to have prompted him to contemplate, and possibly to
intrigue for, his own elevation to the chair of St. Peter, in the event
of a vacancy. His sudden death in 1520, soon after a residence of
above a year as legate to Francis I. (who had conferred upon him
the see of Constance), when coupled with such reports, was
construed as the effect of poison administered by Leo. Indeed, his
friend, Ludovico Canossa, observed that it was a received dogma
among the French at that very time that every man of station who
died in Italy was poisoned. But such vague conjectures, however
specious under Alexander VI., are less credible in other pontificates;
and if the Cardinal were poisoned, that practice was then by no
means limited to popes. He was an accomplished dilettante when
the standards of beauty were of pagan origin; and his intimacy with
Raffaele dated after the painter's Umbrian inspirations had faded
before a gradual homage to the "new manner." Like his friend
Bembo, his morals were epicurean to the full licence of a dissolute
age. His famed comedy of the Calandra,[*47] which was brought out
at Urbino in 1508, and which gave full play to his exquisite sense of
the ridiculous, justifies this charge, and all that we have so often to
repeat of the laxity then prevalent in the most refined Italian circles.
A notice of this, the only important production of his pen, and an
account of its being magnificently performed before Guidobaldo, will
be found in our twenty-fifth chapter. Those who regard the
pontificate of Leo X. as the classic period of Italian letters must feel
grateful to Cardinal Bibbiena for developing a portion of its lustre;
the sterner moralist, who brands its vices, will charge him with
pandering freely to the licence of a court of which he was a notable
ornament. Castiglione tells us that an acute and ready genius
rendered him the delight of all his acquaintance; and Baldi adds,
that by practice in the papal court he so improved that gift, that his
tact in business was unrivalled, to which his mild address, and happy
talent of seasoning the dullest topics with graceful pleasantry,
greatly contributed.
His personal beauty obtained for him the adjunct of bel Bernardo,
and he is represented in the Cortegiano as saying, in reference to
the amount of good looks desirable for a gentleman, "Such grace
and beauty of feature are, I doubt not, mine, in consequence
whereof, as you know, so many women are in love with me; but I
have some misgivings as to my figure, especially these legs of mine,
which, to say the truth, don't seem to me quite what I should like,
though I am well enough satisfied with my bust, and all the rest."
This, however, having been introduced as a jest, may perhaps be
understood rather as complimentary to his person, than as a
sarcasm on his vanity.
A contemporary and unsparing pen thus sketches his qualities, in a
manuscript printed by Roscoe, from the Vatican archives:—"He was
a facetious character, with no mean powers of ridicule, and much
tact in promoting jocular conversation by his wit and well-timed
jests. He was a great favourite with certain cardinals, whose chief
pursuit was pleasure and the chase, for he thoroughly knew all their
habits and fancies, and was even aware of whatever vicious
propensities they had. He likewise possessed a singular pliancy for
flattery, and for obsequiously accommodating himself to their whims,
stooping patiently to be the butt of insulting and abusive jokes, and
shrinking from nothing which could render him acceptable to them.
He also had much readiness in council, and was perfectly able
seasonably to qualify his wit with wisdom, or to dissemble with
singular cunning." Bembo, with more partial pen, says in a letter to
Federigo Fregoso, "The days seem years until I see him, and enjoy
the pleasing society, the charming conversation, the wit, the jests,
the features, and the affection of that man."
Among the distinguished literary names which have issued from
Arezzo, several members of the Accolti family were conspicuous in
the fifteenth and sixteenth centuries. Bernardo,[*48] of whom we are
now to speak, had a father noted as a historian, a brother and a
nephew who reached the dignity of cardinal, and were remarkable in
politics and letters. He obtained from Leo X. the fief of Nepi, as well
as various offices of trust and emolument; of these, however, his
wealth rendered him independent, enabling him to indulge in a life
of literary ease. His poetical celebrity exceeded that of his
contemporaries, and seems to have been his chief recommendation
at the court of Guidobaldo. There, and at Rome, he was in the habit
of reciting his verses in public to vast audiences, composed of all
that was brilliant in these cultivated capitals. Nor was his popularity
limited to a lettered circle. When an exhibition was announced, the
shops were closed, the streets emptied, and guards restrained the
crowds who rushed to secure places among his audience. This
extraordinary enthusiasm appears the more unaccountable, when
we find his printed poetry characterised by a bald and stilted style,
which leaves no pleasing impression on the reader. The mystery
seems explained by a supposition that his talent lay in extemporary
declamation.
Instances are far from uncommon in Italy, of similar effects
produced by the improvisatori, whose torrent of melodious words,
directed to a popular theme, and accompanied by music and
impassioned gesticulation, hurries the feelings of a sympathising
auditory to bursts of tumultuous applause, whilst on cool perusal,
the same compositions fall utterly vapid on the reader. Be this as it
may, the success of Accolti had the common result of superficial
powers, and so egregiously inflated his vanity, that he assumed as
his usual designation "the unique Aretine," by which he is always
accosted in the Cortegiano. Nine years later we find him devoting to
Duchess Elisabetta attentions which were attributed to a passion
more powerful than gratitude, but which, knowing as he well did,
her immaculate modesty, could only have been prompted by
despicable vanity, and hence exposed him to keen ridicule.
To few of the pedigrees illustrated by Sansovino is there attributed a
more remote origin, or a brighter illustration, than to that of Canossa.
[*49] A younger son of the family was Count Ludovico, who, being
cousin-german of Castiglione's mother, was perhaps by this means
brought to Urbino, and thence recommended to Julius II., under
whose patronage he entered upon an ecclesiastical career. From Leo
X. he obtained the see of Tricarico, and was sent by him as nuncio to
England and France, a service which earned him promotion to the
bishopric of Bajus. Adrian VI. and Clement VII. continued him in this
post; and during a long residence at the French court, he entirely
gained the confidence and favour of Francis I. Many of his diplomatic
letters are printed in various collections; and to him is addressed
Count Baldassare's curious description of the performance of the
Calandra, at Urbino.

Alessandro Trivulzio was nephew of Gian Giacomo, the distinguished


Milanese general of that name, and himself a famous captain in the
service of Florence, and of Francis I. Sigismondo Riccardi, surnamed
the Black, Gasparo Pallavicini, Pietro da Napoli, and Roberto da Bari,
—the last of whom died in the camp of Duke Francesco Maria, in
1510,—are mentioned among the military notorieties of the Feltrian
court. Giovanni Cristoforo, the sculptor, may be added to the list of
its literary dilettanti; and among its musical ornaments were Pietro
Monti and Terpandro, with Niccolo Frisio, a German, long resident in
the land of song, whose exertions were often in request by Monti
and Barletta, both dancers of note.
CHAPTER XXII
Emilia Pia—The Cortegiano—Death of Duke Guidobaldo,
succeeded by Francesco Maria della Rovere.

S
UCH were the eminent men, with whom Guidobaldo is
described in the Cortegiano as living in easy but dignified
familiarity, joining their improving and amusing conversation,
or admiring their dexterity in exercises which his broken constitution
no longer permitted him to share. Thus passed the days in the
palace; and, when the Duke was constrained by his infirmities to
seek early repose, the evenings were spent in social amusements,
over which the Duchess gracefully presided, with her ladies
Margherita and Costanza Fregoso, the Duke's nieces, Margherita and
Ippolita Gonzaga, the Signor Raffaella, and Maria Emilia Pia.
ELISABETTA GONZAGA, DUCHESS OF
URBINO
From a lead medal by Adriano Fiorentino in
the British Museum
EMILIA PIA
From a medal by Adriano Fiorentino in the
Vienna Museum

Of the social position of Italian women in this century[*50] we may


gather many particulars from Ludovico Dolce's Instituto delle Donne:
for although, like most writers on similar themes, he represents
them "not as they are, but as they ought to be," still, knowing the
then received standard of female perfection, we can form a pretty
accurate estimate of their actual qualities. His views as to education
are exceedingly orthodox. The Holy Scriptures, with the
commentaries of the fathers, Ambrose, Augustin, and Jerome, ought
to be day and night before a girl, and suffice for her religious and
moral discipline. She should be familiar with her own language and
with Latin, but Greek is an unnecessary burden. For mental
occupation, Plato, Seneca, and such other philosophers as supply
sound moral training are excellent, as well as Cicero for bright
examples and wholesome counsels. History being the teacher of life,
all classical historians are commended, but the Latin poets are
vetoed as unfit for honest women, except most of Virgil and a few
selections from Horace. Many modern Latin writers are commended,
especially the Christeida of Sannazaro and Vida, but all such prurient
productions in Italian as Boccaccio's novels are to be shunned like
venomous reptiles. On the other hand, the poetry of Petrarch and
Dante is extolled beyond measure, the former as embodying with
singular beauty an instance of the purest and most honourable love,
the latter as an admirable portraiture of all Christian philosophy. Yet
such literary occupations should never intrude upon more important
matters, such as prayer, nor upon the domestic duties of married
women.
It is unnecessary to follow our author into abstract qualities and
common-place graces, but the emphasis with which certain things
are decried affords a fair presumption of their prevalence. Thus,
excessive luxury of dress, and, above all, painting the face and
tinging the hair, are attacked as impious attempts to improve upon
God's own handiwork. In like manner, the assiduity with which
modesty and purity of mind and person are inculcated confirms what
we otherwise know of the unbridled licentiousness then widely
diffused over society. Gaming of every sort is scouted; music and
dancing are set down as matters of indifference.
In regard to marriage, the selection of a husband is left as matter of
course to the parents, since a girl is necessarily too ignorant of the
world to choose judiciously for herself; a reason resulting from the
education and social circumstances of young women in Italy, which
sufficiently accounts for this apparent solecism continuing in the
present day. A prolix exposition of the principles which ought to
guide fathers in their discharge of this delicate duty may be summed
up in the very pertinent remark, that few prudent damsels would
rather weep in brocaded silks than smile in homely stuffs.
But it is time to return from this digression to the Lady Emilia Pia, who
merits more special notice in a sketch of the Montefeltrian court. She
was sister of Giberto Pio, Lord of Carpi in Lombardy, and wife of
Antonio, natural brother of Duke Guidobaldo. After losing her
husband in the flower of youth, she remained at Urbino, and became
one of its prime ornaments, not only by her personal attractions, but
by a variety of more lasting qualities. The part she sustains in the
conversation of the Cortegiano amply evinces the charm which
attached to her winning manners, as well as the ready tact
wherewith she played off an extent of knowledge and graceful
accomplishment rare even in that age of female genius. She was at
all times ready and willing to lead or second the learned or sportive
pastimes by which the gay circle gave zest to their intercourse and
polish to their wit, and thus was of infinite use to the Duchess,
whose acquirements were of a less sparkling quality, and of whom
she was the inseparable companion. Still more singular and
proportionately admired were the decorum that marked her conduct
in circumstances of singular difficulty and the virtue which
maintained a spotless reputation amid temptations and lapses
regarded as venial in the habits of a lax age. Her death occurred
about 1530,[*51] and an appropriate posthumous tribute was paid to
such graces and virtues in this medallion bearing her portrait, with
the Latin motto, "To her chaste ashes," on the reverse. Even the
luscious verses in which Bembo and Castiglione sang the seductions
of the Feltrian court assumed a loftier tone in their tribute to her
heart of adamant, which, "pious by name[52] and cruel by nature,"
and spurning the designs of Venus upon its wild freedom, would
impart its own severity generally to the slaves of the goddess. Yet it
was under the guidance of this able mistress of the revels, that joy
and merriment supplanted rigorous etiquette in the palace of Urbino,
where frankness was restrained from excess by the Duchess'
example, and where all were free to promote the common
entertainment as their wit or fancy might suggest. Among the sports
of these after-supper hours, Castiglione enumerates questions and
answers, playful arguments seasoned with smart rejoinders, the
invention of allegories and devices, repartees, mottoes, and puns,
varied by music and dancing.
Alinari
HAIR DRESSING IN THE SIXTEENTH CENTURY
After a picture by Bissolo

Such was the mode of life described in the Cortegiano, with ample
details, which we shall attempt slightly to sketch. The scene is laid in
the evenings immediately succeeding the visit of Julius II. The usual
circle being assembled in her drawing-room, the Duchess desired
Lady Emilia to set some game a-going.[*53] She proposed that every
person in turn should name a new amusement, and that the one
most generally approved should be adopted.[54] This fancy was
sanctioned by her mistress, who delegated to her full authority to
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!

textbookfull.com

You might also like