From solvability and approximation of variational inequalities to solution of nondifferentiable optimization problems in contact mechanics