<P> After Nguyễn Ánh established the Nguyễn dynasty in 1802, he tolerated Catholicism and employed some Europeans in his court as advisors . His successors were more conservative Confucians and resisted Westernization . The next Nguyễn emperors, Minh Mạng, Thiệu Trị, and Tự Đức brutally suppressed Catholicism and pursued a' closed door' policy, perceiving the Westerners as a threat, following events such as the Lê Văn Khôi revolt when a French missionary, Fr . Joseph Marchand, encouraged local Catholics to revolt in an attempt to install a Catholic emperor . Catholics, both Vietnamese and foreign - born, were persecuted in retaliation . Trade with the West slowed during this period . There were frequent uprisings against the Nguyễns, with hundreds of such events being recorded in the annals . These acts were soon being used as excuses for France to invade Vietnam . The early Nguyễn dynasty had engaged in many of the constructive activities of its predecessors, building roads, digging canals, issuing a legal code, holding examinations, sponsoring care facilities for the sick, compiling maps and history books, and exerting influence over Cambodia and Laos . </P> <P> Under the orders of Napoleon III of France, Rigault de Genouilly's gunships attacked the port of Đà Nẵng in 1858, causing significant damage, yet failed to gain any foothold, in the process being afflicted by the humidity and tropical diseases . De Genouilly decided to sail south and captured the poorly defended city of Gia Định (present - day Ho Chi Minh City). From 1859 to 1867, French troops expanded their control over all six provinces on the Mekong delta and formed a colony known as Cochinchina . </P> <P> A few years later, French troops landed in northern Vietnam (which they called Tonkin) and captured Hà Nội twice in 1873 and 1882 . The French managed to keep their grip on Tonkin although, twice, their top commanders Francis Garnier and Henri Rivière, were ambushed and killed fighting pirates of the Black Flag Army hired by the mandarins . France assumed control over the whole of Vietnam after the Tonkin Campaign (1883--1886). French Indochina was formed in October 1887 from Annam (Trung Kỳ, central Vietnam), Tonkin (Bắc Kỳ, northern Vietnam), Cochinchina (Nam Kỳ, southern Vietnam, and Cambodia, with Laos added in 1893). Within French Indochina, Cochinchina had the status of a colony, Annam was nominally a protectorate where the Nguyễn dynasty still ruled, and Tonkin had a French governor with local governments run by Vietnamese officials . </P> <P> After Gia Định fell to French troops, many resistance movements broke out in occupied areas, some led by former court officers, such as Trương Định, some by peasants, such as Nguyễn Trung Trực, who sank the French gunship L'Esperance using guerilla tactics . In the north, most movements were led by former court officers and lasted decades, with Phan Đình Phùng fighting in central Vietnam until 1895 . In the northern mountains, former bandit leader Hoàng Hoa Thám fought until 1911 . Even the teenage Nguyễn Emperor Hàm Nghi left the Imperial Palace of Huế in 1885 with regent Tôn Thất Thuyết and started the Cần Vương ("Save the King") movement, trying to rally the people to resist the French . He was captured in 1888 and exiled to French Algeria . Guerrillas of the Cần Vương movement murdered around a third of Vietnam's Christian population during the rebellion . Decades later, two more Nguyễn kings, Thành Thái and Duy Tân were also exiled to Africa for having anti-French tendencies . The former was deposed on the pretext of insanity and Duy Tân was caught in a conspiracy with the mandarin Trần Cao Vân trying to start an uprising . However, lack of modern weapons and equipment prevented these resistance movements from being able to engage the French in open combat . The various anti-French revolts started by mandarins were carried out with the primary goal of restoring the old feudal society . However, by 1900 a new generation of Vietnamese were coming of age who had never lived in precolonial Vietnam . These young activists were as eager as their grandparents to see independence restored, but they realized that returning to the feudal order was not feasible and that modern technology and governmental systems were needed . Having been exposed to Western philosophy, they aimed to establish a republic upon independence, departing from the royalist sentiments of the Cần Vương movements . Some of them set up Vietnamese independence societies in Japan, which many viewed as a model society (i.e. an Asian nation that had modernized, but retained its own culture and institutions). </P>

What was vietnam called when it was a colony
find me the text answering this question