Example usage for javax.servlet.jsp JspWriter print

List of usage examples for javax.servlet.jsp JspWriter print

Introduction

In this page you can find the example usage for javax.servlet.jsp JspWriter print.

Prototype


abstract public void print(Object obj) throws IOException;

Source Link

Document

Print an object.

Usage

From source file:no.kantega.publishing.api.taglibs.util.AbbreviateTag.java

/**
 * Rendrer endret body.//from   ww w. j  a  v  a 2  s .  co  m
 *
 * @return
 * @throws JspException
 */
public int doEndTag() throws JspException {

    try {
        JspWriter out = pageContext.getOut();
        out.print(text);
    } catch (IOException ioe) {
        throw new JspException(ioe.toString());
    }
    return EVAL_PAGE;

}

From source file:info.magnolia.cms.taglibs.util.Xmp.java

/**
 * @see javax.servlet.jsp.tagext.Tag#doEndTag()
 *//*w w  w  . ja v a2s. com*/
public int doEndTag() {
    JspWriter out = pageContext.getOut();
    String xmpString = getBodyContent().getString();
    try {
        out.print(StringEscapeUtils.escapeHtml(xmpString));
    } catch (IOException e) {
        // should never happen
        throw new NestableRuntimeException(e);
    }
    return EVAL_PAGE;
}

From source file:com.feilong.taglib.AbstractWriteContentTag.java

/**
 * ?./*  w w w . j a  v a  2s. c o m*/
 *
 * @param object
 *            the object
 * @since 1.5.3 move from {@link BaseTag}
 */
protected void print(Object object) {
    JspWriter jspWriter = pageContext.getOut();
    try {
        jspWriter.print(object);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

From source file:org.squale.welcom.taglib.optimization.ScriptTag.java

/**
 * @see javax.servlet.jsp.tagext.TagSupport#doEndTag()
 *//*ww  w .  ja  va 2  s . c  o  m*/
public int doEndTag() throws JspException {
    final JspWriter writer = pageContext.getOut();

    try {
        writer.print("<script type=\"text/JavaScript\" src=\"");
        writer.print(src + "\"");
        if (!GenericValidator.isBlankOrNull(charset)) {
            writer.print(" charset=\"" + charset + "\"");
        }
        writer.print(">");
        writer.print("</script>");
    } catch (final IOException e) {
        throw new JspException(e.getMessage());
    }

    return EVAL_PAGE;
}

From source file:com.draagon.meta.web.tag.MetaObjectTag.java

public int doStartTag() throws JspException {
    try {/*  www .  j  av a 2 s .c  om*/
        Object o = pageContext.getRequest().getAttribute(getName());
        if (o == null)
            return Tag.SKIP_BODY;

        //log.debug( "(doStartTag) Meta Object found with id [" + mo.getId() + "]" );

        MetaObject mc = MetaDataLoader.findMetaObject(o);

        if (mc == null) {
            log.error("Cannot find MetaClass for object [" + o + "]");
            return Tag.SKIP_BODY;
        }

        MetaField mf = mc.getMetaField(getField());
        if (mf == null) {
            log.error("Cannot find MetaField for MetaClass [" + mc + "] with name [" + getField() + "]");
            return Tag.SKIP_BODY;
        }

        String val = mf.getString(o);

        if (getVar() == null) {
            JspWriter out = pageContext.getOut();
            if (val != null)
                out.print(val);
        } else {
            pageContext.setAttribute(getVar(), val, PageContext.PAGE_SCOPE);
        }
    } catch (Exception e) {
        log.error("Error processing Meta Object Tag [name:" + getName() + ", field:" + getField() + "]", e);
        throw new JspException(
                "Error processing Meta Object Tag [name:" + getName() + ", field:" + getField() + "]: " + e);
    }

    return Tag.SKIP_BODY;
}

From source file:ru.ac.ugatu.asu.core.tags.settingStringValue.java

@Override
protected int doStartTagInternal() throws Exception {
    JspWriter out = this.pageContext.getOut();
    Setting setting = this.getSettingService().getSetting(this.getSettingsAlias());
    if (setting != null) {
        out.print(setting.getValue());
    }//  w ww.  j  a  v a 2  s .  c om
    return RequestContextAwareTag.EVAL_BODY_INCLUDE;
}

From source file:org.openmrs.web.taglib.PatientWidgetTag.java

public int doStartTag() {

    /*//www .  ja v a  2 s  .  co  m
    WebApplicationContext messageSource = WebApplicationContextUtils.getWebApplicationContext(pageContext.getServletContext());
    if (messageSource == null) {
       log.error("servletContext = " + pageContext.getServletContext());
       log.error("WebApplicationContextUtils.getWebApplicationContext(pageContext.getServletContext()) returns null");
    }
    */
    boolean showNames = "full".equals(size);
    boolean showPatientInfo = !"compact".equals(size);
    Patient patient = null;
    if (showPatientInfo) {
        patient = Context.getPatientService().getPatient(patientId);
    }

    try {
        JspWriter w = pageContext.getOut();
        if (showNames && patient != null) {
            w.print(patient.getNames().iterator().next());
        } else {
            w.print("patient_id " + patientId);
        }
        if (showPatientInfo) {
            if (patient.getGender() != null) {
                //String s = messageSource.getMessage("Patient.gender." + (patient.getGender().toLowerCase().startsWith("m") ? "male" : "female"), null, locale);
                String s = patient.getGender().toLowerCase().startsWith("m") ? "Male" : "Female";
                w.print(", " + s);
            }
            if (patient.getAge() != null) {
                //Object[] msgArgs = { patient.getAge() };
                //w.print(", " + messageSource.getMessage("Person.age.yearsOld", msgArgs, locale));
                w.print(", " + patient.getAge() + " year(s) old");
            }
        }
    } catch (IOException ex) {
        log.error("Error while starting patientWidget tag", ex);
    }
    return SKIP_BODY;
}

From source file:org.onehippo.forge.properties.tags.PropertyTag.java

protected void handleValue(final String value, final HstRequest hstRequest) {

    final String message = StringEscapeUtils.escapeXml(value);
    final String escapedValue = MessageFormat.format(message,
            parametersList.toArray(new Object[parametersList.size()]));
    if (var != null) {
        hstRequest.setAttribute(var, escapedValue);
    } else {//from  w w  w  .ja va 2s  . c o m
        JspWriter writer = pageContext.getOut();
        try {
            writer.print(escapedValue);
        } catch (IOException ioe) {
            throw new RuntimeException(ioe);
        }
    }
}

From source file:ams.fwk.customtag.AmsUploadTag.java

/**
 * @return int//from   w w w.ja  va  2s  .  c o  m
 * @throws JspException
 */
public int doEndTag() throws JspException {
    try {
        List uploads = Collections.EMPTY_LIST;
        if (fileSeqNo != null && fileSeqNo.trim().length() > 0) {
            uploads = getUploads();
        }

        JspWriter out = pageContext.getOut();
        out.print(listOpen);
        int count = 0;
        for (Iterator all = uploads.iterator(); all.hasNext();) {

            Map each = (Map) all.next();
            if ("N/A".equals(typeId) || typeId.equals(each.get("TYPE_ID"))) {
                String temp = StringUtils.replace(listItem, "$filename$", (String) each.get("FILE_NAME"));
                temp = StringUtils.replace(temp, "$max$", "" + max);
                temp = StringUtils.replace(temp, "$typeId$", typeId);
                temp = StringUtils.replace(temp, "$fileId$", (String) each.get("FILE_ID"));
                temp = StringUtils.replace(temp, "$filepath$",
                        StringEscapeUtils.escapeJavaScript((String) each.get("FILE_PATH")));

                out.print(temp);
                count++;

            }
        }
        if (max > count) {
            String requiredTemp = "";
            String temp = "";
            if ("Y".equals(isRequired)) {
                requiredTemp = StringUtils.replace(requiredTag, "$requiredMsg$",
                        StringUtils.isEmpty(requiredMsg) ? "" : requiredMsg);
                temp = StringUtils.replace(fileItem, "$requiredTag$", "" + requiredTemp);
            } else {
                temp = StringUtils.replace(fileItem, "$requiredTag$", "" + "");
            }
            temp = StringUtils.replace(temp, "$max$", "" + max);
            temp = StringUtils.replace(temp, "$typeId$", typeId);
            if ("Y".equals(eachSeqNoFlag)) {
                temp += StringUtils.replace(hiddenTag, "$id$", "eachSeqNoFlag");
                temp = StringUtils.replace(temp, "$name$", "eachSeqNoFlag");
                temp = StringUtils.replace(temp, "$value$", "" + "Y");
            }
            out.print(temp);
        }
        out.print(listClose);

        return EVAL_PAGE;
    } catch (IOException e) {
        throw new JspException(e);
    } finally {
        fileSeqNo = null;
        typeId = "N/A";
        max = 1;
    }
}

From source file:dk.netarkivet.common.webinterface.HTMLUtils.java

/**
 * Prints the header information for the webpages in the GUI. This includes the navigation menu, and links for
 * changing the language.//from w w w. j  a  va 2s . c  om
 *
 * @param title An internationalised title of the page.
 * @param context The context of the web page request.
 * @param refreshInSeconds auto-refresh time in seconds
 * @throws IOException if an error occurs during writing to output.
 */
public static void generateHeader(String title, long refreshInSeconds, PageContext context) throws IOException {
    ArgumentNotValid.checkNotNull(title, "title");
    ArgumentNotValid.checkNotNull(context, "context");

    JspWriter out = context.getOut();
    String url = ((HttpServletRequest) context.getRequest()).getRequestURL().toString();
    Locale locale = context.getResponse().getLocale();
    title = escapeHtmlValues(title);
    log.debug("Loaded URL '" + url + "' with title '" + title + "'");
    out.print(WEBPAGE_HEADER_TEMPLATE_TOP);
    if (refreshInSeconds > 0) {
        out.print(WEBPAGE_HEADER_AUTOREFRESH.replace(TITLE_PLACEHOLDER, Long.toString(refreshInSeconds)));
    }
    out.print(WEBPAGE_HEADER_TEMPLATE_BOTTOM.replace(TITLE_PLACEHOLDER, title).replace(JS_PLACEHOLDER, ""));
    // Start the two column / one row table which fills the page
    out.print("<table id =\"main_table\"><tr>\n");
    // fill in data in the left column
    generateNavigationTree(out, url, locale);
    // The right column contains the active form content for this page
    out.print("<td valign = \"top\" >\n");
    // Language links
    generateLanguageLinks(out);
}