In the festival of tabernacles there is a moment where the high priest circles the altar with freshly drawn water. This is called the water-libation. The libation offering of water came at the end of the last day of the festival (note "on the last day of the festival, the great day" in verse 37). It is at this moment, when the priest has returned from the pool of Siloam with the freshly drawn water and is pouring the water out onto the alter as a libation offering and the participants are celebrating with flutes, and thew waving of branches, singing and dancing that Jesus calls out: "let anyone who is thirsty come to me . . . out of the believers heart shall flow rivers of living water." What follows is a discussion of whether or not Jesus is the prophet.
In John's gospel, Jesus is engaging the existing festivals and reinterpreting them. Much as Jesus takes the Passover and shifts the emphasis to "this is my body and this is my blood" so with the feast of the tabernacles, Jesus takes the pouring of the water libation (the high holy moment on the 7th day of the festival) and transforms it into a fresh understanding of the giving of the Holy Spirit. For the believer, coming to Jesus will mean an infilling of the Holy Spirit, a fresh pouring out of God's presence and power.
I notice in Verse 50 that our old friend, Nicodemus, is back. Remember John 3, Nicodemus came to Jesus by night and left somewhat confused. It appears that by chapter 7, Nicodemus is in the position of defending Jesus and reminding the Sanhedrin council that their procedures do not allow them to judge a person without a fair hearing. The council's response is to accuse Nicodemus of being a follower of Jesus (see verse 52). We know, later in the gospel, that Nicodemus IS a follower of Jesus when he comes to help Joseph of Arimathea with Jesus' burial.