protected TreeControl getTreeControl() throws JspException {
    Object treeControl = null;

    if (scope == null) {
      HttpSession session = pageContext.getSession();

      if ((session.getAttribute(tree + "type") != null)
          && ((String) session.getAttribute(tree + "type")).equals("0")) {
        treeControl = null;
      } else {
        treeControl = pageContext.getSession().getAttribute(tree);
      }

      if (treeControl == null) {
        TreeControl control = null;
        TreeControlNode root =
            new TreeControlNode(
                "ROOT-NODE", null, null, "setupTree.do?select=ROOT-NODE", "content", true, "Root");
        control = new TreeControl(root);

        TreeBuilder builder = TreeBuilderFactory.getTreeBuilder(tree, id);

        if (builder != null) {
          builder.buildTree(control, null, (HttpServletRequest) pageContext.getRequest());
        }

        treeControl = control;
        session.setAttribute(tree, control);
      }

      return (TreeControl) treeControl;
    } else if ("page".equals(scope)) {
      treeControl = pageContext.getAttribute(tree, PageContext.PAGE_SCOPE);
    } else if ("request".equals(scope)) {
      treeControl = pageContext.getAttribute(tree, PageContext.REQUEST_SCOPE);
    } else if ("session".equals(scope)) {
      treeControl = pageContext.getAttribute(tree, PageContext.SESSION_SCOPE);
    } else if ("application".equals(scope)) {
      treeControl = pageContext.getAttribute(tree, PageContext.APPLICATION_SCOPE);
    }

    System.out.println("TreeControl = " + treeControl);

    if (treeControl == null) {
      throw new JspException("Cannot find tree control attribute '" + tree + "'");
    } else if (!(treeControl instanceof TreeControl)) {
      throw new JspException("Invalid tree control attribute '" + tree + "'");
    } else {
      return ((TreeControl) treeControl);
    }
  }