The history of this idea is not more than 200 years old. Nationalism, in the sense in which we use it today, did not exist in India before the 19th century. The roots (origins) of this idea do not lie in the Indian history but in the history of Modern Europe.
In fact it is possible to talk of Indian nationalism as distinctly different from its European counterpart. In order to know this difference it is important to have an idea of the circumstances under which nationalism took roots in Europe.
In Europe the development of nationalism was the result of the fundamental changes that were taking place in society and economy around the 18th century. The beginning of the industrial revolution produced goods and materials and created wealth at an unprecedented level. This led to the need for the creation of a unified and large market where these goods could be sold.
The creation of a large market led to a political integration of villages, districts and provinces into a larger state. In this large and complex market different people were required to perform different roles for which they needed to be trained in different skills. But above all they needed to communicate with each other. This created the need for uniform educational centres with focus on one language.
In the pre-modern times majority of the people learnt language and other skills in their local environments which differed from each other. But now, because of the new changes brought about by modern economy, a uniform system of training and schooling came into being. Thus, modern English language in England, French in France and German in Germany became the dominant language in those countries.
Uniformity in communication systems resulted in the creation of a "national culture" and reinforced national boundaries. People living within those boundaries began to associate themselves with it. Culturally they also began to perceive themselves as one people and as members of one large community, i.e. Englishmen began to identify with each other and with the geographical boundaries of England. Similarly it happened to German and French people. This was the beginning of the idea of nationalism.
Nationalism was the result of the emergence of nations and nation states (large culturally homogenous territories with a uniform political system within) in Europe. These nation states did not always exist. The early societies, with simpler forms of human organizations and without an elaborate division of labour, could easily manage their affairs without a state or a central authority to enforce law and order.
State, as a central authority, came into being after the beginning of organized agriculture. People generally found it difficult to manage their lives without a central authority to regulate their lives. This need for a state became even greater with the onset of industrialization and a modern world economy. An elaborate system of communication and a uniform system of education with focus on one standardized language created conditions for cultural and political uniformity.
Thus came into being modern nation states. These nation states, in order to sustain and perpetuate themselves, needed the allegiance and loyalty of the people residing in their territories. This was the beginning of nationalism. In other words, an identification by a people or community with the boundary of the Nation, state and its high culture gave rise to what we know as nationalism.
But this was not how the idea of nationalism developed in India. The conditions in India were very different at a time when the idea of nationalism was taking roots in Europe. Industrialization occurred here at a very limited scale. When Europe was getting rapidly industrialized, India was still largely an agrarian economy. Different people spoke different languages. Though the feeling of patriotism, certainly existed in India in pre-modern times. But nationalism as we understand it (unified system of administration, common language, a shared high culture and political integration) did not exist in India until about the middle of the 19th century.
Nationalism in India developed primarily as a response to the British rule. British rule came to the Indian soil in 1757 with battle of Plassey and gradually established here by defeating the native rulers. The arrival of the British as rulers was resented by many of the native rulers and people also. It was clear that they all wanted to oppose and fight against the British presence in India.
But initially they did not do it together or as one people. Different groups had their specific grievances against the British and therefore they fought for the redressal of their specific grievances. For instance the native rulers did not want the British to take over their territories (as it happened to the rulers of Awadh and Jhansi in present day U.P.).
Similarly peasants, artisans and tribals suffered at the hands of the British rulers and often stood up in revolt against them. But merely the opposition to the British rule or a fight against them did not bring about a feeling of nationalism in India. Although different sections of the population got united because of common exploitation at the hands of the British, a feeling of identification with the entire country and its people did not come about.
Even the great revolt of 1857, in which many sections of the population fought together (like native rulers, soldiers, zamindars and peasants) did not produce a feeling of nationalism or an all-India unity. The idea that the people of India, in spite of many differences among themselves, had many things in common amongst them had not, as yet, taken roots.
Similarly the realization that the British rule was foreign and an alien rule which wanted to subjugate the entire people and bring them under its control, had also not occurred. The essence of nationalism in India, or Indian nationalism, was the realization that all the Indian people had a common nationality and that it was in their collective interests to resist the British rule. To put it simply, a combined opposition to British rule and desire to achieve national unity lay at the heart of Indian nationalism.
The objective conditions for the development of nationalism were indeed fulfilled by the arrival of the colonial rulers and their penetration into Indian society and economy. However, these conditions in themselves, did not create an awareness of nationalism among the people. The consciousness of the idea of nationalism took a long time to mature and made its presence gradually in the fields of culture, economy and politics.