The Jain answers that one should practise some kind of asceticism and abstain from killing, stealing, misconduct in sensual pleasures, lying.
The Buddha pointed out that, even when undertaking these practises, one can still experience pleasure and pain. So you cannot achieve perfect splendour just by following this route.
He went further, and said that that there was practical way to realise an exclusively pleasant world. Can you guess what it is? In case you hadn't guessed, it's this: "quite secluded from sensual pleasures, secluded from unwholesome states, a bhikkhu enters upon and abides in the first jhana ... second jhana ... third jhana".
Section 27 is interesting. The Buddha says that it is at the fourth jhana that the meditator realises an exclusively pleasant world. He also say, somewhat curiously, "He dwells with those deities who have arisen in an entirely pleasant world and he talks with them and enters into conversation with them". The translator notes that this corresponds to the world of Refulgent Glory. This is a bit puzzling, because they are the ones that experience the third jhana. There seems to be an incompatibility there.
The Buddha then points out that it is not for the sake of the fourth jhana that he gives his teachings, for there are states higher than this.
When someone reaches the fourth jhana, they should direct their mind to the recollection of past lives, then to the knowledge of the passing away and reappearance of beings. A monk once explained to me that by recollecting past lives, one becomes unshakeably convinced about the mechanism of kamma. So it's not an activity for amusement's sake, it has a practical purpose in the attainment of the goal.
After that, he directs his knowledge to the destruction of the taints. "He understands as it actually is: 'This is suffering' ... 'this is the way leading to the cessation of taints' .... 'When he knows and sees this, his mind is liberated from the taint of sensual desire .... being ... ignorance'. He understands: 'Birth is destroyed, the holy life has been lived, ...'" and so on. This is the purpose of the Buddha's teachings.