It was one swift attack that managed to push the Gondorians out of the eastern half of the town, that also marked the beginning of the war, and one surprise attack with boats 9 months later to take the western half that a few weeks before the end of the war.
I don't know if it's mentioned anywhere what happened in the meantime, but Denethor says he's expecting an enemy strike against Osgiliath shortly before the second attack happens, so it can't have been an active frontline at the time.