He drank the bitter cup to the end, as the song we sing sometimes says. Similarly, the image of Baptism also points to the cross experience of Jesus. In the verses immediately before the passage we are dealing with today, Jesus tells them that the Son of Man is going to Jerusalem to be betrayed, condemned, executed, and that he would rise again after three days. But they still did not fully understand what he was going on about. Jesus used this imagery of baptism in at least one other place in the Gospels.
Baptism is something associated with grief and repentance for sin.
It is also symbolic of being plunged into death and rising again. Jesus of course didn't have to repent of his own sin, but he did bear the grief associated with all our sin, and he was baptised into death and then back up again to life, just as someone goes into the waters and comes back up again. That's why Jesus tells James and John that they don't know what they are asking. They do not realise that the path to glory lies through the valley of the shadow of death. Jesus himself, let alone any who would follow him, cannot sit down in glory before he first goes through the most terrible suffering for the sake of the gospel of God.