People have to answer again and again the same old question because their previous answers are lost somewhere in the forum and cannot be easily unearthed. Answers should be more systematically added to the wiki. At least for the question "How do I get rid of prisonners", the answer was quite hard to find for me. I did not find a solution experimenting on my own. Then, I searched on the wiki, and the explanations were not satisfying. Then I searched on this forum, and the answers that were detailed enough were lost among lots of partial answers.
If you understand that assigning a creature to a cage or a pit makes the dwarves release the creature from their initial cage, you are still far from having a satisfying solution: the creatures escape, hurt your dwarves, make your military run and so on.
That is where I was after experimenting by myself, and I made no progress after having read the wiki, and still no progress after having read 4 posts on the question I found on this forum: you tend to find answers like "Drop them in a pit and shoot them with your marksdwarves" or "I use my prisonners to train my military in an arena".
But you have to explore the forum more in depth to find things about building the cage, and using a lever to release the creature, and this does not explain yet how to chose the right cage. It took me ages before noticing the e'x'pand option (It was not on the wiki page about cages until I found this option and added a word about it). And for dropping the creatures in a pit without them escaping, I finally found a post saying that the solution is to build the animal stockpile just next to the pit so that the creature doesn't have time to escape.