The Mousetrap is the play within the play: a staging of a king's murder by poison in the ear, which Hamlet has the actors perform before Claudius to see whether he betrays himself. Hamlet commissions it as The Murder of Gonzago and gives it the name The Mousetrap only when the king asks.
At the end of Act II, after seeing an actor weep for Hecuba, he lays out the plan: "The play's the thing wherein I'll catch the conscience of the King." He asks the actors for twelve or sixteen lines written by him and, in Act III, scene 2, asks Horatio to watch the king's face.
A pantomime and then the play show a man pouring poison into the ear of the sleeping king in an orchard, as the ghost described. Asked its name, Hamlet answers: "The Mousetrap. Well, how? Figuratively." Claudius rises, calls out "Give me some light. Away!" and leaves. Hamlet tells Horatio that he takes "the ghost's word for a thousand pounds," and Horatio replies: "Very well, my lord."
The king's reaction is not a confession. The confession comes soon after, when Claudius, alone, says "A brother's murder!", unheard by Hamlet. Shortly afterward, in the queen's chamber, Hamlet thrusts through the curtain and says "How now? A rat?", convinced he strikes the king, and it is Polonius who dies.