htmlRenderContext = HtmlProcessContextImpl .getHtmlProcessContext(facesContext.getExternalContext());
htmlProcessContext = HtmlProcessContextImpl .getHtmlProcessContext(facesContext);
    public int doEndTag() throws JspException {        JspWriter writer = pageContext.getOut();        FacesContext facesContext = FacesContext.getCurrentInstance();        htmlRenderContext = HtmlProcessContextImpl                .getHtmlProcessContext(facesContext.getExternalContext());        boolean opened = false;        try {            if (requiredFiles != null || requiredClasses != null) {                boolean useMetaScript = htmlRenderContext                        .useMetaContentScriptType()                        && InitializeTag.isMetaDataInitialized(pageContext);                opened = addRequires(facesContext, writer, useMetaScript,                        requiredFiles, requiredClasses);            }        } catch (IOException ex) {            throw new JspException(ex);        }        BodyContent bodyContent = getBodyContent();        try {            if (src != null || bodyContent != null) {                boolean useScriptCData = htmlRenderContext.useScriptCData();                if (opened && src != null) {                    if (useScriptCData) {                        writer.println(IHtmlRenderContext.JAVASCRIPT_CDATA_END);                    }                    writer.println("</SCRIPT>");                    opened = false;                }                boolean needScriptCData = false;                if (opened == false) {                    boolean useMetaScript = htmlRenderContext                            .useMetaContentScriptType()                            && InitializeTag.isMetaDataInitialized(pageContext);                    writer.print("<SCRIPT");                    if (useMetaScript == false) {                        writer.write(" type=\"");                        writer.write(IHtmlRenderContext.JAVASCRIPT_TYPE);                        writer.write('"');                    }                    if (src != null) {                        src = rewriteURL(null, src);                        src = reformatSource(src);                        writer.write(" src=\"");                        writer.write(src);                        writer.write('"');                        String javascriptCharset = IHtmlRenderContext.JAVASCRIPT_CHARSET;                        if (javascriptCharset != null) {                            writer.write(" charset=\"");                            writer.write(javascriptCharset);                            writer.write('"');                        }                    }                    writer.print('>');                    opened = true;                    needScriptCData = useScriptCData;                }                if (src == null) {                    if (needScriptCData) {                        writer.print(IHtmlRenderContext.JAVASCRIPT_CDATA_BEGIN);                        writer.println();                    }                    bodyContent.writeOut(writer);                    if (useScriptCData) {                        writer.println(IHtmlRenderContext.JAVASCRIPT_CDATA_END);                    }                }            }            if (opened) {                writer.print("</SCRIPT>");            }        } catch (IOException ex) {            throw new JspException(ex);        }        return super.doEndTag();    }