A Commentary, Critical, Practical, and Explanatory on the Old and New Testaments, by Robert Jamieson, A.R. Fausset and David Brown  at sacred-texts.com
jos 2:1RAHAB RECEIVES AND CONCEALS THE TWO SPIES. (Jos 2:1-7)
Joshua . . . sent . . . two men to spy secretly--Faith is manifested by an active, persevering use of means (Jam 2:22); and accordingly Joshua, while confident in the accomplishment of the divine promise (Jos 1:3), adopted every precaution which a skilful general could think of to render his first attempt in the invasion of Canaan successful. Two spies were despatched to reconnoitre the country, particularly in the neighborhood of Jericho; for in the prospect of investing that place, it was desirable to obtain full information as to its site, its approaches, the character, and resources of its inhabitants. This mission required the strictest privacy, and it seems to have been studiously concealed from the knowledge of the Israelites themselves, test any unfavorable or exaggerated report, publicly circulated, might have dispirited the people, as that of the spies did in the days of Moses.
Jericho--Some derive this name from a word signifying "new moon," in reference to the crescent-like plain in which it stood, formed by an amphitheater of hills; others from a word signifying "its scent," on account of the fragrance of the balsam and palm trees in which it was embosomed. Its site was long supposed to be represented by the small mud-walled hamlet Er-Riha; but recent researches have fixed on a spot about half an hour's journey westward, where large ruins exist about six or eight miles distant from the Jordan. It was for that age a strongly fortified town, the key of the eastern pass through the deep ravine, now called Wady-Kelt, into the interior of Palestine.
they . . . came into an harlot's house--Many expositors, desirous of removing the stigma of this name from an ancestress of the Saviour (Mat 1:5), have called her a hostess or tavern keeper. But Scriptural usage (Lev 21:7-14; Deu 23:18; Jdg 11:1; Kg1 3:16), the authority of the Septuagint, followed by the apostles (Heb 11:31; Jam 2:25), and the immemorial style of Eastern khans, which are never kept by women, establish the propriety of the term employed in our version. Her house was probably recommended to the spies by the convenience of its situation, without any knowledge of the character of the inmates. But a divine influence directed them in the choice of that lodging-place.
jos 2:2it was told the king--by the sentinels who at such a time of threatened invasion would be posted on the eastern frontier and whose duty required them to make a strict report to headquarters of the arrival of all strangers.
jos 2:4the woman took the two men, and hid them--literally, "him," that is, each of them in separate places, of course previous to the appearance of the royal messengers and in anticipation of a speedy search after her guests. According to Eastern manners, which pay an almost superstitious respect to a woman's apartment, the royal messengers did not demand admittance to search but asked her to bring the foreigners out.
jos 2:5the time of shutting of the gates--The gates of all Oriental cities are closed at sunset, after which there is no possibility either of admission or egress.
the men went out--This was a palpable deception. But, as lying is a common vice among heathen people, Rahab was probably unconscious of its moral guilt, especially as she resorted to it as a means for screening her guests; and she might deem herself bound to do it by the laws of Eastern hospitality, which make it a point of honor to preserve the greatest enemy, if he has once eaten one's salt. Judged by the divine law, her answer was a sinful expedient; but her infirmity being united with faith, she was graciously pardoned and her service accepted (Jam 2:25).
jos 2:6she had brought them up to the roof of the house, and hid them with the stalks of flax--Flax, with other vegetable productions, is at a certain season spread out on the flat roofs of Eastern houses to be dried in the sun; and, after lying awhile, it is piled up in numerous little stacks, which, from the luxuriant growth of the flax, rise to a height of three or four feet. Behind some of these stacks Rahab concealed the spies.
jos 2:7the men pursued after them the way to Jordan unto the fords--That river is crossed at several well-known fords. The first and second immediately below the sea of Galilee; the third and fourth immediately above and below the pilgrims' bathing-place, opposite Jericho.
as soon as they which pursued after them were gone out, they shut the gate--This precaution was to ensure the capture of the spies, should they have been lurking in the city.
jos 2:8THE COVENANT BETWEEN HER AND THEM. (Jos 2:8-21)
she came up unto them upon the roof and said--Rahab's dialogue is full of interest, as showing the universal panic and consternation of the Canaanites on the one hand (Jos 24:11; Deu 2:25), and her strong convictions on the other, founded on a knowledge of the divine promise, and the stupendous miracles that had opened the way of the Israelites to the confines of the promised land. She was convinced of the supremacy of Jehovah, and her earnest stipulations for the preservation of her relatives amid the perils of the approaching invasion, attest the sincerity and strength of her faith.
jos 2:14the men answered her, Our life for yours, if ye utter not this our business--This was a solemn pledge--a virtual oath, though the name of God is not mentioned; and the words were added, not as a condition of their fidelity, but as necessary for her safety, which might be endangered if the private agreement was divulged.
jos 2:15her house was upon the town wall--In many Oriental cities houses are built on the walls with overhanging windows; in others the town wall forms the back wall of the house, so that the window opens into the country. Rahab's was probably of this latter description, and the cord or rope sufficiently strong to bear the weight of a man.
jos 2:16she said--rather "she had said," for what follows must have been part of the previous conversation.
Get you to the mountain--A range of white limestone hills extends on the north, called Quarantania (now Jebel Karantu), rising to a height of from twelve hundred to fifteen hundred feet, and the sides of which are perforated with caves. Some one peak adjoining was familiarly known to the inhabitants as "the mountain." The prudence and propriety of the advice to flee in that direction rather than to the ford, were made apparent by the sequel.
jos 2:21she bound the scarlet line in the window--probably soon after the departure of the spies. It was not formed, as some suppose, into network, as a lattice, but simply to hang down the wall. Its red color made it conspicuous, and it was thus a sign and pledge of safety to Rahab's house, as the bloody mark on the lintels of the houses of the Israelites in Egypt to that people.