Constrained lower semicontinuity problems in the calculus of variations