This method will write out the <code>String</code> returned by <code>getErrorsReport</code> to the
response output stream.
@throws JspException if <code>write</code> throws an exception.
@see #getErrorsReport
493069
public void reportErrors(Writer writer, String tagName)
            throws JspException
    {
        try {
            writer.write(getErrorsReport(tagName));
        }
        catch (IOException e) {
            JspException jspException = new JspException(e.getMessage(), e);

            // todo: future cleanup
            // The 2.5 Servlet api will set the initCause in the Throwable superclass during construction,
            // this will cause an IllegalStateException on the following call.
            if (jspException.getCause() == null) {
                jspException.initCause(e);
            }
            throw jspException;
        }
    }
555114
private void writeError(I_CmsReport report, Throwable e) {

        report.println(e);
        if (LOG.isWarnEnabled()) {
            LOG.warn("SQLConsole", e);
        }
    }
502436
public int doEndTag() throws JspException
    {
        ServletRequest req = pageContext.getRequest();
        Object textObject = null;

        // Get the value of the data source.  The object will not be null.
        Object val = evaluateDataSource();
        textObject = (val != null) ? val : "";
        assert(textObject != null);

        // setup the rest of the state.
        ByRef ref = new ByRef();
        nameHtmlControl(_state, ref);

        _state.disabled = isDisabled();

        // if there were expression errors report them
        if (hasErrors())
            return reportAndExit(EVAL_PAGE);

        // if there were format errors then report them
        if (_formatErrors) {
            if (bodyContent != null) {
                String value = bodyContent.getString().trim();
                bodyContent.clearBody();
                write(value);
            }
        }

        // create the input tag.
        WriteRenderAppender writer = new WriteRenderAppender(pageContext);
        TagRenderingBase br = TagRenderingBase.Factory.getRendering(TagRenderingBase.TEXT_AREA_TAG, req);
        br.doStartTag(writer, _state);

        // create the text value which will be found inside the textarea.
        if ((textObject == null) || (textObject.toString().length() == 0)) {
            textObject = _defaultValue;
        }

        String text = formatText(textObject);
        if (text != null) {
            // make sure leading blank line in the text value is not interpreted
            // just as formatting... force a new line for formatting
            if (text.startsWith("\n") || text.startsWith("\r")) {
                writer.append("\n");
            }
            HtmlUtils.filter(text, writer);
        }

        //results.append(text);
        br.doEndTag(writer);

        // if there are errors report them...
        if (hasErrors())
            return reportAndExit(EVAL_PAGE);

        // report any script
        if (!ref.isNull())
            write((String) ref.getRef());

        localRelease();
        return EVAL_PAGE;
    }
909784
public static void writeString(ByteBuffer buffer, String s) throws IOException {
    if(s == null) {
      s = ""; // Which will be written as Varint 0 = single byte 0.
    }
    ByteArrayUtil.STRING_SERIALIZER.toByteBuffer(buffer, s);
  }
172822
public void setErrorReturn(PrintWriter out, RemoteException ex)
        throws RemoteException
    {
        out.println(Utility.startTag(XMLTags.STATUS_TEXT));
        String strMessage = ex.getLocalizedMessage();
        if (Utility.isNumeric(strMessage))
        {
            try {
                int iErrorCode = Integer.parseInt(strMessage);
                out.println(Utility.startTag(XMLTags.ERROR_CODE) + strMessage + Utility.endTag(XMLTags.ERROR_CODE));
                if (this.getTask() != null)
                    if (this.getTask().getApplication() != null)
                        strMessage = this.getTask().getApplication().getSecurityErrorText(iErrorCode);
            } catch (NumberFormatException ex2) {
                // Ignore
            }
        }
        out.println(Utility.startTag(XMLTags.TEXT) + strMessage + Utility.endTag(XMLTags.TEXT));
        out.println(Utility.startTag(XMLTags.ERROR) + "error" + Utility.endTag(XMLTags.ERROR));
        out.println(Utility.endTag(XMLTags.STATUS_TEXT));
        return;
    }
1095259
private void write(String s)
            throws SAXException {
        try {
            out.write(s);
            out.flush();
        } catch (IOException ioException) {
            throw new SAXParseException("I/O error",
                    documentLocator,
                    ioException);
        }
    }
297718
public int doEndTag() throws JspException
    {
        ServletRequest req = pageContext.getRequest();

        // Create an appropriate "input" element based on our parameters
        if (_password) {
            _state.type = INPUT_PASSWORD;
        }
        else {
            _state.type = INPUT_TEXT;
        }


        // Create the state for the input tag
        ByRef ref = new ByRef();
        nameHtmlControl(_state, ref);

        _state.disabled = isDisabled();

        // Create the text value of the TextBox
        Object textObject = evaluateDataSource();
        if ((textObject == null) || (textObject.toString().length() == 0)) {
            textObject = _defaultValue;
        }

        // Get the text value for the textbox, the result
        String text = null;
        if (textObject != null) {
            text = formatText(textObject);
            InternalStringBuilder sb = new InternalStringBuilder(text.length() + 16);
            StringBuilderRenderAppender sbAppend = new StringBuilderRenderAppender(sb);
            HtmlUtils.filter(text, sbAppend);
            text = sb.toString();
        }
        _state.value = text;

        // if there were format errors then report them
        if (_formatErrors) {
            if (bodyContent != null) {
                String value = bodyContent.getString().trim();
                bodyContent.clearBody();
                write(value);
            }
        }

        if (hasErrors())
            return reportAndExit(EVAL_PAGE);

        // create the input tag.
        WriteRenderAppender writer = new WriteRenderAppender(pageContext);
        TagRenderingBase br = TagRenderingBase.Factory.getRendering(TagRenderingBase.INPUT_TEXT_TAG, req);
        assert(br != null);

        br.doStartTag(writer, _state);
        br.doEndTag(writer);

        // write any script that needs to be written
        if (!ref.isNull())
            write((String) ref.getRef());

        localRelease();
        return EVAL_PAGE;
    }
521348
@Override
  final public void write(String s)
    throws IOException
  {
    if (s == null) {
      write(_nullChars, 0, _nullChars.length);
      return;
    }
    
    write(s, 0, s.length());
  }
50120
public int doEndTag() throws JspException
    {
        Object val = evaluateDataSource();

        ServletRequest req = pageContext.getRequest();

        if (_dataInput != null) {
            val = _dataInput.toString();
        }

        // if there were expression errors report them
        if (hasErrors())
            return reportAndExit(SKIP_BODY);

        if (val != null) {
            _value = val.toString();
        }

        // Create an appropriate "input" element based on our parameters
        ByRef ref = new ByRef();
        nameHtmlControl(_state, ref);

        if (_value != null) {
            InternalStringBuilder sb = new InternalStringBuilder(_value.length() + 16);
            StringBuilderRenderAppender sbAppend = new StringBuilderRenderAppender(sb);
            HtmlUtils.filter(_value, sbAppend);
            _state.value = sb.toString();
        }

        // correct for null text here
        if (_state.value == null)
            _state.value = "";

        WriteRenderAppender writer = new WriteRenderAppender(pageContext);
        TagRenderingBase hiddenTag = TagRenderingBase.Factory.getRendering(TagRenderingBase.INPUT_HIDDEN_TAG, req);

        hiddenTag.doStartTag(writer, _state);
        hiddenTag.doEndTag(writer);

        if (!ref.isNull())
            write((String) ref.getRef());

        // Continue processing this page
        localRelease();
        return SKIP_BODY;
    }
282504
public void write(ByteCodeWriter out)
    throws IOException
  {
    out.writeUTF8Const(getName());

    TempOutputStream ts = new TempOutputStream();
    //ts.openWrite();
    //WriteStream ws = new WriteStream(ts);
    ByteCodeWriter o2 = new ByteCodeWriter(ts, out.getJavaClass());

    o2.writeShort(_exceptions.size());
    for (int i = 0; i < _exceptions.size(); i++) {
      String exn = _exceptions.get(i);

      o2.writeClass(exn);
    }
    
    ts.close();
    
    out.writeInt(ts.getLength());
    
    TempBuffer ptr = ts.getHead();

    for (; ptr != null; ptr = ptr.next())
      out.write(ptr.buffer(), 0, ptr.length());

    ts.destroy();
  }
6900
public static void writeString(DataOutput out, String s) throws IOException {
        if (s != null) {
            byte[] buffer = s.getBytes("UTF-8");
            int len = buffer.length;
            out.writeInt(len);
            out.write(buffer, 0, len);
        } else {
            out.writeInt(-1);
        }
    }
246834
@Override
    public void onWriteError(Exception ex, List<? extends File> items) {
        log.error("Error writing item(s): " + items.toString(), ex);
    }
696285
public void println(String s) throws IOException
  {
    if(s!=null) {
        this.output.write(s.getBytes(), 0, s.length());
    }
    this.output.write(CRLF, 0, 2);
  }
677229
public void render() throws IOException, JspException {

        boolean isNewFunctionType = OpenCms.getResourceManager().matchResourceType(
            CmsResourceTypeFunctionConfig.TYPE_NAME,
            m_element.getResource().getTypeId());
        if (isNewFunctionType) {
            CmsFunctionFormatterBean function = getFormatterBean(m_cms);
            if (function != null) {
                CmsUUID jspId = function.getRealJspId();
                if (jspId != null) {
                    CmsJspTagInclude.includeTagAction(
                        m_context,
                        m_cms.getRequestContext().removeSiteRoot(function.getRealJspRootPath()),
                        null,
                        m_cms.getRequestContext().getLocale(),
                        false,
                        m_cms.getRequestContext().getCurrentProject().isOnlineProject(),
                        function.getParameters(),
                        CmsRequestUtil.getAttributeMap(m_request),
                        m_request,
                        m_response);
                } else {
                    m_context.getOut().print(defaultHtml(m_request));
                }
            } else {
                m_context.getOut().print(defaultHtml(m_request));
            }
        } else {
            CmsDynamicFunctionBean.Format format = getFunctionFormat();
            if ((format != null) && m_cms.existsResource(format.getJspStructureId())) {
                try {
                    CmsResource jspResource = m_cms.readResource(format.getJspStructureId());
                    Map<String, String[]> params = new HashMap<>();
                    for (Entry<String, String> paramEntry : format.getParameters().entrySet()) {
                        params.put(paramEntry.getKey(), new String[] {paramEntry.getValue()});
                    }
                    CmsJspTagInclude.includeTagAction(
                        m_context,

                        m_cms.getSitePath(jspResource),
                        null,
                        m_cms.getRequestContext().getLocale(),
                        false,
                        m_cms.getRequestContext().getCurrentProject().isOnlineProject(),
                        params,
                        CmsRequestUtil.getAttributeMap(m_request),
                        m_request,
                        m_response);
                } catch (CmsException e) {
                    LOG.error(e.getLocalizedMessage(), e);
                }
            } else {
                m_context.getOut().print(defaultHtml(m_request));
            }
        }
    }
199604
protected void writeError(final ApiRequest request, final HttpServletResponse resp, final Throwable error) {
        getErrorWriter().write(request, error, new IApiClientResponse() {
            @Override
            public void write(StringBuffer buffer) {
                write(buffer.toString());
            }

            @Override
            public void write(StringBuilder builder) {
                write(builder.toString());
            }

            @Override
            public void write(String body) {
                try {
                    resp.getOutputStream().write(body.getBytes("UTF-8")); //$NON-NLS-1$
                    resp.getOutputStream().flush();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

            /**
             * @see io.apiman.gateway.engine.IApiClientResponse#setStatusCode(int)
             */
            @Override
            public void setStatusCode(int code) {
                resp.setStatus(code);
            }

            @Override
            public void setHeader(String headerName, String headerValue) {
                resp.setHeader(headerName, headerValue);
            }
        });
    }
1164045
public void doTag()
            throws JspException
    {
        // report any errors...
        if (hasErrors()) {
            reportErrors();
            return;
        }

        // calculate the output value...
        String text;
        if (_value != null) {
            text = _value.toString();
        }
        else {
            if (_defaultValue != null) {
                text = _defaultValue;
            }
            else {
                logger.warn(Bundle.getString("Tags_ContentExpressionNull", _value));
                text = DEFAULT_NULL_TEXT;
            }
        }

        write(text);
    }
1089329
public int doEndTag() throws JspException
    {
        ServletRequest req = pageContext.getRequest();

        String fmtErrors = null;
        if (_formatterError) {
            fmtErrors = getErrorsFromBody();
        }
        if (hasErrors())
            return reportAndExit(EVAL_PAGE);

        _state.disabled = isDisabled();

        //Create hidden field for state tracking
        ByRef ref = new ByRef();
        nameHtmlControl(_state, ref);

        if (hasErrors())
            return reportAndExit(EVAL_PAGE);

        // Only write out the hidden field if the select is not
        // disabled.  If it is disabled, then nothing will be posted
        // back from this.
        WriteRenderAppender writer = new WriteRenderAppender(pageContext);
        if (!_state.disabled) {
            _hiddenState.clear();
            String hiddenParamName = null;
            hiddenParamName = _state.name + OLDVALUE_SUFFIX;
            _hiddenState.name = hiddenParamName;
            _hiddenState.value = "true";

            TagRenderingBase hiddenTag = TagRenderingBase.Factory.getRendering(TagRenderingBase.INPUT_HIDDEN_TAG, req);
            hiddenTag.doStartTag(writer, _hiddenState);
            hiddenTag.doEndTag(writer);
            write("\n");
        }

        // Render any formatting errors that may have occurred.
        if (fmtErrors != null)
            write(fmtErrors);


        TagRenderingBase br = TagRenderingBase.Factory.getRendering(TagRenderingBase.SELECT_TAG, req);
        br.doStartTag(writer, _state);

        // Render the content of the body, these would be the options
        if (_saveBody != null) {
            write(_saveBody);
        }

        // if we are repeating then the body contained the options so we can exit here
        if (_repeater) {

            if (hasErrors())
                return reportAndExit(EVAL_PAGE);

            br.doEndTag(writer);
            if (!ref.isNull())
                write((String) ref.getRef());

            // Continue processing this page
            localRelease();
            return EVAL_PAGE;
        }

        // All of the code below will pass through the optionsDataSource, the dataSource and defaultValue and
        // create a full Select.
        if (_dynamicOptions != null) {
            if (_dynamicOptions instanceof Map) {
                Map dynamicOptionsMap = (Map) _dynamicOptions;
                Iterator keyIterator = dynamicOptionsMap.keySet().iterator();
                while (keyIterator.hasNext()) {
                    Object optionValue = keyIterator.next();
                    String optionDisplay = null;
                    if (dynamicOptionsMap.get(optionValue) != null) {
                        optionDisplay = dynamicOptionsMap.get(optionValue).toString();
                    }

                    if (optionValue != null) {
                        addOption(req, optionValue.toString(), optionDisplay);
                    }
                }
            }
            else if (_dynamicOptions instanceof Iterator) {
                Iterator dynamicOptionsIterator = (Iterator) evaluateOptionsDataSource();
                while (dynamicOptionsIterator.hasNext()) {
                    Object o = dynamicOptionsIterator.next();
                    if (o != null) {
                        String optionValue = o.toString();
                        addOption(req, optionValue, optionValue);
                    }
                }
            }
        }

        // add the value from the DataSource and Default value
        addDatasourceIfNeeded(req);
        addDefaultsIfNeeded(req);
        if (_nullable && !isMultiple()) {
            String txt = (_nullableOptionText != null) ? _nullableOptionText : "";
            addOption(req, NULL_VALUE, txt);
        }

        br.doEndTag(writer);
        if (!ref.isNull())
            write((String) ref.getRef());

        // Continue processing this page
        localRelease();
        return EVAL_PAGE;
    }