LPS-50629 adapt from ee-6.2.x

Changes were forward ported from ee-6.2.x.
LPS-50629 fix unbalanced jsp
LPS-50619 SF