William Shakespeare used this device notably in Hamlet The play within the play In Hamlet the protagonist uses the representation of a tragedy called Murder of Gonzago and its primary function is to trap Claudius into revealing his guilt.This is why he also refers to the play as "The Mousetrap". Infact the play shows a story that is very similar to the events happened to the old King of Denmark; if Claudius was guilty he would seem to be worried.
HAMLET SIMPLE PLOT
To do this, when a troupe of actors come to the castle, Hamlet decides to prepare the “mouse-trap” for his uncle.So, he asks to the first actor to make some changes to the original play and to perform it with the right emphasis. The play is a simple story that talks about a queen and a king poisoned by his nephew to obtain the power. After the murder the poisoner and the queen merry. So, in the evening, the tragedy was organized in the mead hall of the castle with the presence of the king and the court. Before the beginning of the play Hamlet asks to his friend Horatio, that he trusts blindly, to observe carefully the king's behavior while the tragedy is going on. During the play when Luciano, the poisoner, kills the king, Hamlet sees that Claudius is going away, and he understands that he is guilty. With this trick Hamlet provokes his uncle and sums this up by saying "the play's the thing wherein I'll catch the conscience of the king." Now he finally is sure that the ghost said the truth about his death.
The reactions of the characters: King Claudius: he understands that Hamlet has discover his guilt. He is worried about what he could do and so he wants to send him in England with the help of Rosencrantz and Guildenstern Queen Gertrude: she is anguished and worried for his son. She is also perplexed and amazed because she doesn't know what Hamlet's intentions and thoughts are. Horatio: he is the only real and truth friend of Hamlet and so he knows hamlet's purpose and he has to finds out king's reaction.