How is the theme of spying related with the theme of prison in Hamlet?
These two themes really cannot be separated in Hamlet. First of all, if you are being spied upon, it is like being imprisoned as someone is watching your every move and you have no privacy. Thus, the "prison-house" world of Hamlet is illustrated through Claudius spying upon Hamlet; Polonious spying upon Hamlet and Ophelia;Claudius and Polonious spying upon Hamlet and Ophelia; and Polonious spying upon Gertrude and Hamlet which leads to Polonious's death. Polonious even has a spy follow his son, Laertes, to France. Also, Rosencrantz and Guildenstern are paid by Claudius and Gertrude to spy upon Hamlet which results in their deaths. Interestingly enough, Hamlet and Horatio also become spies as they watch Claudius, paradoxically, watching the play of his murder of King Hamlet, most definitely, a prison-house world!
Hamlet mentions that he feels imprisoned in Denmark which points not only to his "trapped" feeling of his father's murder, his mother's quick marriage to his uncle, and his birthright robbed from him. In addition, they are both watching Hamlet to see how all these events will effect him. Claudius moreso than Gertrude, since he is trying to figure out if Hamlet knows he is the guilty murderer.