In Jail, Joseph interprets a cup bearer and a bakers dreams. Joseph says that the cup bearer's dream means that in three days Pharaoh will release the cup bearer and the Pharaoh will give him back his job. Joseph then told the baker that his dream meant in three days time the Pharaoh will hang him.
Two Whole Years later Joseph was asked to interpret the Pharaoh's dream and Joseph was taken out of Jail. The Pharaoh's Dream had shown 7 years of greatness and 7 years of drought and famine.
The Pharaoh was impressed by Joseph and told him that he would be in charge of preparing for the drought. The Pharaoh also gave Joseph the name Zaphnath-Paaneah.
During the drought Joseph's brothers went to Egypt to buy Grain they did not recognize Joseph but Joseph knew who they were so he told them to go back and get the youngest, Benjamin who had stayed home with their father Jacob and Joseph would lock one of the brothers up until they returned with Benjamin.
Joseph Decided to put his treasured Goblet that was given to him from the Pharaoh in Benjamin's bag so that they would be stopped when they went to leave after the had found the goblet in Benjamin's bag Joseph was going to kill Benjamin but Judah said "No, take me instead" Joseph saw this as forgiveness and reveled who he was to them.