LPS-38516 Moved logic from start.jsp to end.jsp
LPS-38516 Added buffering and write condition
LPS-38516 Adding null check (Not related to the bug)