Active immunity is generated by
Exposure to a dead pathogen
Active immunity could be developed in the body on being exposed to a live pathogen. Here the pathogen establishes an infection, which is then subdued in time and immunity is built due to the formation of memory cells. Exposure to a dead pathogen as in the case of vaccines, wherein dead and weakened pathogens are administered, also induces active immunity.