GEOMETRY OF LAGRANGIAN AND HAMILTONIAN FORMALISMS IN THE DYNAMICS OF STRINGS