<% String foo = ""; %>
...
<%
  if (output != null) {
    try {
      foo = output;
    } catch (Exception e) {
      foo = "";
    }
  }
%>