/* "onunload='...'" */
public int doEndTag()
        throws JspTagException
    {
        HttpServletRequest request = (HttpServletRequest)super.pageContext.getRequest();
        RequestProperties reqState = (RequestProperties)request.getAttribute(SECTION_REQUESTPROPS);
        PrivateLabel     privLabel = (reqState != null)? reqState.getPrivateLabel() : RequestProperties.NullPrivateLabel;
        JspWriter              out = super.pageContext.getOut();
        String                   s = this.getSection().toLowerCase();
        /* ignore blank section definitions */
        if (StringTools.isBlank(s)) {
            // -- ignore
            return EVAL_PAGE;
        }
        /* not a match? */
        if (!this.isMatch()) {
            // -- ignore
            return EVAL_PAGE;
        }
        // --------------------------------------------------------------------
        /* "onload='...'" */
        if (s.equalsIgnoreCase(SECTION_BODY_ONLOAD)) {
            String bodyOnLoad = (String)request.getAttribute(SECTION_BODY_ONLOAD);
            if (!StringTools.isBlank(bodyOnLoad)) {
                try {
                    out.print(bodyOnLoad);
                } catch (IOException ioe) {
                    throw new JspTagException(ioe.toString());
                }
            }
            return EVAL_PAGE;
        }
        /* "onunload='...'" */
        if (s.equalsIgnoreCase(SECTION_BODY_ONUNLOAD)) {
            String bodyOnUnload = (String)request.getAttribute(SECTION_BODY_ONUNLOAD);
            if (!StringTools.isBlank(bodyOnUnload)) {
                try {
                    out.print(bodyOnUnload);
                } catch (IOException ioe) {
                    throw new JspTagException(ioe.toString());
                }
            }
            return EVAL_PAGE;
        }
        // --------------------------------------------------------------------
        /* expandMenu style */
        if (s.equalsIgnoreCase(SECTION_MENU_STYLE)) {
            try {
                ExpandMenu.writeStyle(out, reqState);
            } catch (IOException ioe) {
                throw new JspTagException(ioe.toString());
            }
            return EVAL_PAGE;
        }
        /* expandMenu javascript */
        if (s.equalsIgnoreCase(SECTION_MENU_JAVASCRIPT)) {
            try {
                ExpandMenu.writeJavaScript(out, reqState);
            } catch (IOException ioe) {
                throw new JspTagException(ioe.toString());
            }
            return EVAL_PAGE;
        }
        /* expandMenu */
        if (s.equalsIgnoreCase(SECTION_MENU)) {
            try {
                ExpandMenu.writeMenu(out, reqState, 
                    null/*menuID*/, true/*expandableMenu*/, 
                    false/*showIcon*/, ExpandMenu.DESC_LONG, false/*showMenuHelp*/);
            } catch (IOException ioe) {
                throw new JspTagException(ioe.toString());
            }
            return EVAL_PAGE;
        }
        // --------------------------------------------------------------------
        /* content table class */
        if (s.equalsIgnoreCase(SECTION_CONTENT_CLASS_TABLE)) {
            HTMLOutput content = (HTMLOutput)request.getAttribute(SECTION_CONTENT_BODY);
            if (content != null) {
                try {
                    String tableClass = content.getTableClass();
                    out.write(!StringTools.isBlank(tableClass)? tableClass : "contentTableClass");
                } catch (IOException ioe) {
                    throw new JspTagException(ioe.toString());
                }
            }
            return EVAL_PAGE;
        }
        /* content cell class */
        if (s.equalsIgnoreCase(SECTION_CONTENT_CLASS_CELL)) {
            HTMLOutput content = (HTMLOutput)request.getAttribute(SECTION_CONTENT_BODY);
            if (content != null) {
                try {
                    String cellClass = content.getCellClass();
                    out.write(!StringTools.isBlank(cellClass)? cellClass : "contentCellClass");
                } catch (IOException ioe) {
                    throw new JspTagException(ioe.toString());
                }
            }
            return EVAL_PAGE;
        }
        /* content message id */
        if (s.equalsIgnoreCase(SECTION_CONTENT_ID_MESSAGE)) {
            try {
                out.write(CommonServlet.ID_CONTENT_MESSAGE);
            } catch (IOException ioe) {
                throw new JspTagException(ioe.toString());
            }
            return EVAL_PAGE;
        }
        /* content message class */
        if (s.equalsIgnoreCase(SECTION_CONTENT_CLASS_MESSAGE)) {
            try {
                out.write(CommonServlet.CSS_CONTENT_MESSAGE);
            } catch (IOException ioe) {
                throw new JspTagException(ioe.toString());
            }
            return EVAL_PAGE;
        }
        /* content menubar */
        if (s.equalsIgnoreCase(SECTION_CONTENT_MENUBAR)) {
            HTMLOutput content = (HTMLOutput)request.getAttribute(SECTION_CONTENT_BODY);
            if (content != null) {
                String contentClass = content.getTableClass();
                try {
                    if (ListTools.contains(CommonServlet.CSS_MENUBAR_OK,contentClass)) {
                        MenuBar.writeTableRow(out, reqState.getPageName(), reqState);
                    } else {
                        out.write("<!-- no menubar ['"+contentClass+"'] -->");
                    }
                } catch (IOException ioe) {
                    throw new JspTagException(ioe.toString());
                }
            }
            return EVAL_PAGE;
        }
        /* content message */
        if (s.equalsIgnoreCase(SECTION_CONTENT_MESSAGE)) {
            HTMLOutput content = (HTMLOutput)request.getAttribute(SECTION_CONTENT_BODY);
            String msg = (content != null)? StringTools.trim(content.getTableMessage()) : "";
            try {
                out.write(msg); // TODO: HTML encode?
            } catch (IOException ioe) {
                throw new JspTagException(ioe.toString());
            }
            return EVAL_PAGE;
        }
        // --------------------------------------------------------------------
        /* request context path */
        if (s.equalsIgnoreCase(SECTION_REQUEST_CONTEXT)) {
            try {
                out.write(request.getContextPath());
            } catch (IOException ioe) {
                throw new JspTagException(ioe.toString());
            }
            return EVAL_PAGE;
        }
        // --------------------------------------------------------------------
        /* CSS file */
        if (s.equalsIgnoreCase(SECTION_CSSFILE)) {
            String cssFilePath = this.getArg();
            if (!StringTools.isBlank(cssFilePath)) {
                try {
                    PrintWriter pw = new PrintWriter(out, out.isAutoFlush());
                    WebPageAdaptor.writeCssLink(pw, reqState, cssFilePath, null);
                } catch (IOException ioe) {
                    throw new JspTagException(ioe.toString());
                }
            }
            return EVAL_PAGE;
        }
        // --------------------------------------------------------------------
        /* Banner Image Height */
        if (s.equalsIgnoreCase(SECTION_BANNER_WIDTH)) {
            // key suffix
            String kSfx = StringTools.trim(this.getArg());
            // property values
            String bannerWidth = privLabel.getStringProperty(PrivateLabel.PROP_Banner_width   + kSfx, null);
            if (StringTools.isBlank(bannerWidth)) {
                bannerWidth = privLabel.getStringProperty(PrivateLabel.PROP_Banner_imageWidth + kSfx, null);
            }
            // minimum valie
            if (StringTools.isBlank(bannerWidth)) {
                bannerWidth = this.hasDefault()? this.getDefault() : "100%";
            } else
            if (!bannerWidth.endsWith("%")) {
                int W = StringTools.parseInt(bannerWidth, 0);
                bannerWidth = String.valueOf((W < MIN_BANNER_WIDTH)? MIN_BANNER_WIDTH : W);
            }
            // generate html
            try {
                out.write(bannerWidth);
            } catch (IOException ioe) {
                throw new JspTagException(ioe.toString());
            }
            return EVAL_PAGE;
        }
        /* Banner Style */
        if (s.equalsIgnoreCase(SECTION_BANNER_STYLE)) {
            // key suffix
            String kSfx = StringTools.trim(this.getArg());
            // property values
            String bannerStyle = privLabel.getStringProperty(PrivateLabel.PROP_Banner_style + kSfx, null);
            // generate html
            if (!StringTools.isBlank(bannerStyle)) {
                try {
                    out.write(bannerStyle);
                } catch (IOException ioe) {
                    throw new JspTagException(ioe.toString());
                }
            } else
            if (this.hasDefault()) {
                try {
                    out.write(this.getDefault());
                } catch (IOException ioe) {
                    throw new JspTagException(ioe.toString());
                }
            }
            return EVAL_PAGE;
        }
        /* Banner Image */
        if (s.equalsIgnoreCase(SECTION_BANNER_IMAGE)) {
            // key suffix
            String kSfx      = StringTools.trim(this.getArg());
            // property values
            String imgLink   = privLabel.getStringProperty(PrivateLabel.PROP_Banner_imageLink   + kSfx, null);
            String imgSrc    = privLabel.getStringProperty(PrivateLabel.PROP_Banner_imageSource + kSfx, null);
            String imgWidth  = privLabel.getStringProperty(PrivateLabel.PROP_Banner_imageWidth  + kSfx, null);
            String imgHeight = privLabel.getStringProperty(PrivateLabel.PROP_Banner_imageHeight + kSfx, null);
            // generate html
            if (!StringTools.isBlank(imgSrc)) {
                StringBuffer sb = new StringBuffer();
                if (!StringTools.isBlank(imgLink)) { 
                    sb.append("<a href='").append(imgLink).append("' target='_blank'>"); 
                }
                sb.append("<img src='").append(imgSrc).append("' border='0'");
                if (!StringTools.isBlank(imgWidth)) {
                    sb.append(" width='").append(imgWidth).append("'");
                }
                if (!StringTools.isBlank(imgHeight)) {
                    sb.append(" height='").append(imgHeight).append("'");
                }
                sb.append(">");
                if (!StringTools.isBlank(imgLink)) {
                    sb.append("</a>");
                }
                try {
                    out.write(sb.toString());
                } catch (IOException ioe) {
                    throw new JspTagException(ioe.toString());
                }
            } else
            if (this.hasDefault()) {
                try {
                    out.write(this.getDefault());
                } catch (IOException ioe) {
                    throw new JspTagException(ioe.toString());
                }
            }
            return EVAL_PAGE;
        }
        /* Banner Image */
        if (s.equalsIgnoreCase(SECTION_BANNER_IMAGE_SOURCE)) {
            // key suffix
            String kSfx      = StringTools.trim(this.getArg());
            // property values
            String imgSrc    = privLabel.getStringProperty(PrivateLabel.PROP_Banner_imageSource + kSfx, null);
            // generate html
            if (!StringTools.isBlank(imgSrc)) {
                //Print.sysPrintln("Property Image Source: " + imgSrc);
                try {
                    out.write(imgSrc);
                } catch (IOException ioe) {
                    throw new JspTagException(ioe.toString());
                }
            } else
            if (this.hasDefault()) {
                //Print.sysPrintln("Default Image Source: " + this.getDefault());
                try {
                    out.write(this.getDefault());
                } catch (IOException ioe) {
                    throw new JspTagException(ioe.toString());
                }
            }
            return EVAL_PAGE;
        }
        /* Banner Image Height */
        if (s.equalsIgnoreCase(SECTION_BANNER_IMAGE_WIDTH)) {
            // key suffix
            String kSfx      = StringTools.trim(this.getArg());
            // property values
            String imgWidth  = privLabel.getStringProperty(PrivateLabel.PROP_Banner_imageWidth  + kSfx, null);
            // generate html
            if (!StringTools.isBlank(imgWidth)) {
                try {
                    out.write(imgWidth);
                } catch (IOException ioe) {
                    throw new JspTagException(ioe.toString());
                }
            } else
            if (this.hasDefault()) {
                try {
                    out.write(this.getDefault());
                } catch (IOException ioe) {
                    throw new JspTagException(ioe.toString());
                }
            }
            return EVAL_PAGE;
        }
        /* Banner Image Height */
        if (s.equalsIgnoreCase(SECTION_BANNER_IMAGE_HEIGHT)) {
            // key suffix
            String kSfx      = StringTools.trim(this.getArg());
            // property values
            String imgHeight = privLabel.getStringProperty(PrivateLabel.PROP_Banner_imageHeight + kSfx, null);
            // generate html
            if (!StringTools.isBlank(imgHeight)) {
                try {
                    out.write(imgHeight);
                } catch (IOException ioe) {
                    throw new JspTagException(ioe.toString());
                }
            } else
            if (this.hasDefault()) {
                try {
                    out.write(this.getDefault());
                } catch (IOException ioe) {
                    throw new JspTagException(ioe.toString());
                }
            }
            return EVAL_PAGE;
        }
        // --------------------------------------------------------------------
        /* JavaScript */
        if (s.equalsIgnoreCase(SECTION_JAVASCRIPT)) {
            try {
                // always write "utils.js"
                JavaScriptTools.writeUtilsJS(out, request);
                // check for other javascript 
                Object obj = request.getAttribute(SECTION_JAVASCRIPT);
                if (obj instanceof HTMLOutput) {
                    ((HTMLOutput)obj).write(out); 
                } else {
                    out.write("<!-- Unexpected section type '" + s + "' [" + StringTools.className(obj) + "] -->"); 
                }
            } catch (IOException ioe) {
                throw new JspTagException(ioe.toString());
            }
            return EVAL_PAGE;
        }
        // --------------------------------------------------------------------
        /* current page name */
        if (s.equalsIgnoreCase(SECTION_PAGE_NAME)) { // "pagename"
            String pageName = reqState.getPageName();
            if (!StringTools.isBlank(pageName)) {
                try {
                    out.write(pageName);
                } catch (IOException ioe) {
                    throw new JspTagException(ioe.toString());
                }
            }
            return EVAL_PAGE;
        }
        // --------------------------------------------------------------------
        /* Page URL */
        if (s.equalsIgnoreCase(SECTION_PAGE_URL)) { // "pageurl"
            String pageName = this.getArg();
            String cmd      = null;
            String cmdArg   = null;
            WebPage wp = privLabel.getWebPage(pageName);
            String url = (wp != null)? wp.encodePageURL(reqState,cmd,cmdArg) : null;
            if (!StringTools.isBlank(url)) {
                try {
                    out.write(url);
                } catch (IOException ioe) {
                    throw new JspTagException(ioe.toString());
                }
            }
            return EVAL_PAGE;
        }
        // --------------------------------------------------------------------
        /* HTMLOutput */
        try {
            Object obj = request.getAttribute(s);
            if (obj == null) {
                out.write("<!-- Undefined section '" + s + "' -->"); 
            } else
            if (obj instanceof HTMLOutput) {
                ((HTMLOutput)obj).write(out); 
            } else {
                out.write("<!-- Unexpected section type '" + s + "' [" + StringTools.className(obj) + "] -->"); 
            }
        } catch (IOException ioe) {
            throw new JspTagException(ioe.toString());
        }
        return EVAL_PAGE;
    }
return EVAL_PAGE;
}
/* "onunload='...'" */
if (s.equalsIgnoreCase(SECTION_BODY_ONUNLOAD)) {
String bodyOnUnload = (String)request.getAttribute(SECTION_BODY_ONUNLOAD);
String bodyOnLoad = (String)request.getAttribute(SECTION_BODY_ONLOAD);
if (!StringTools.isBlank(bodyOnLoad)) {
try {
out.print(bodyOnLoad);
} catch (IOException ioe) {
throw new JspTagException(ioe.toString());
}
}
return EVAL_PAGE;
}
/* "onunload='...'" */
if (s.equalsIgnoreCase(SECTION_BODY_ONUNLOAD)) {
String bodyOnUnload = (String)request.getAttribute(SECTION_BODY_ONUNLOAD);
if (!StringTools.isBlank(bodyOnUnload)) {
try {
out.print(bodyOnUnload);
} catch (IOException ioe) {
throw new JspTagException(ioe.toString());
}
}
return EVAL_PAGE;
return EVAL_PAGE;
}
/* not a match? */
if (!this.isMatch()) {
// -- ignore
return EVAL_PAGE;
}
// --------------------------------------------------------------------
/* "onload='...'" */
if (s.equalsIgnoreCase(SECTION_BODY_ONLOAD)) {
String bodyOnLoad = (String)request.getAttribute(SECTION_BODY_ONLOAD);
if (!StringTools.isBlank(bodyOnLoad)) {
try {
out.print(bodyOnLoad);
} catch (IOException ioe) {
throw new JspTagException(ioe.toString());
}
}
return EVAL_PAGE;
}
/* "onunload='...'" */
if (s.equalsIgnoreCase(SECTION_BODY_ONUNLOAD)) {
String bodyOnUnload = (String)request.getAttribute(SECTION_BODY_ONUNLOAD);
if (!StringTools.isBlank(bodyOnUnload)) {
try {
out.print(bodyOnUnload);
} catch (IOException ioe) {
throw new JspTagException(ioe.toString());
}
}
return EVAL_PAGE;
}
// --------------------------------------------------------------------
/* expandMenu style */
if (s.equalsIgnoreCase(SECTION_MENU_STYLE)) {
try {
ExpandMenu.writeStyle(out, reqState);
} catch (IOException ioe) {
throw new JspTagException(ioe.toString());
}
return EVAL_PAGE;