Have now found the 1st marriage of the John Glenday from Cupar - he married in Chatham, Kent before he went to India.
John Glenday, of full age, Private - 50 Regt., address 'Barracks', father John Glenday, Linen Manufacturer.
Margaret Patterson, of full age, address 'River House', father James Patterson, Baker.
married 27th June 1840 St. Mary's, Chatham, Kent
1. This confirms he was the son of John Glenday (from his occupation) in Cupar.
2. If he was indeed born 1822 he told a 'porkie' as he would only have been 18!
Perhaps Margaret went with him to India, possibly dying en route - certainly can't see any children born to John and Margaret in India, nor a death for a Margaret.
So, 'your' John, the father of William, is clearly the other John Glenday in 3rd. Battalion Artillery who married Frances Oliver in 1841 (as James?) in India.
At this point we do not know when/where this John Glenday was born but the fact that his will appears on FindMyPast dated in 1848 would indicate he died then or soon after (and also why no more children after 1848).
You need to locate and get a check done of Muster Rolls from 1841 to 1848 in Madras. This should then give you the details of where he came from and his age.
Annette