Classical solutions of forced vibration of rod and beam driven by displacement boundary conditions