Nuclear mean field on and near the drip lines