當前位置: 首頁>>代碼示例>>Java>>正文


Java JspWriter類代碼示例

本文整理匯總了Java中javax.servlet.jsp.JspWriter的典型用法代碼示例。如果您正苦於以下問題:Java JspWriter類的具體用法?Java JspWriter怎麽用?Java JspWriter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JspWriter類屬於javax.servlet.jsp包,在下文中一共展示了JspWriter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doEndTag

import javax.servlet.jsp.JspWriter; //導入依賴的package包/類
/**
 * Does two things:
 * <ul>
 *      <li>Stops the page if the corresponding attribute has been set</li>
 *      <li>Prints a message another tag encloses this one.</li>
 * </ul>
 */
public int doEndTag() throws JspTagException
{
    //get the parent if any
    Tag parent = this.getParent();

    if (parent != null) {
        try {
            JspWriter out = this.pageContext.getOut();
            out.println("This tag has a parent. <BR>");

        } catch (IOException e) {
            throw new JspTagException(e.getMessage());
        }
    }

    if (this.stopPage) {

        return Tag.SKIP_PAGE;
    }

    return Tag.EVAL_PAGE;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:30,代碼來源:SampleTag.java

示例2: writeTagBodyContent

import javax.servlet.jsp.JspWriter; //導入依賴的package包/類
/** This generates the HTML for the tag.
 * @param out The JspWriter object.
 * @param bodyContent The BodyContent object.
 * @throws IOException if any I/O error occurs.
 */
public void writeTagBodyContent(JspWriter out, BodyContent bodyContent) throws IOException {
    
    // clear the body content for the next time through.
    bodyContent.clearBody();
    
    // get the model
    TableModel model = null;
    try {
        model = (TableModel) TagHelper.getModel(pageContext, getField(), TAG_NAME);
    } catch (ClassCastException e) {
        String str = "Wrong WidgetModel for " + TAG_NAME + " on field " + getField();
        log.error(str, e);
        throw new JspWriteRuntimeException(str, e);
    }
    
    if (model != null) {
        // write out the html
        String idPrefix = getHtmlIdPrefix();
        out.println( getHtml(idPrefix, model));
    }
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:27,代碼來源:TableTag.java

示例3: pushBody

import javax.servlet.jsp.JspWriter; //導入依賴的package包/類
public JspWriter pushBody(Writer writer) {
	depth++;
	if (depth >= outs.length) {
		BodyContentImpl[] newOuts = new BodyContentImpl[depth + 1];
		for (int i = 0; i < outs.length; i++) {
			newOuts[i] = outs[i];
		}
		newOuts[depth] = new BodyContentImpl(out);
		outs = newOuts;
	}

	outs[depth].setWriter(writer);
	out = outs[depth];

	// Update the value of the "out" attribute in the page scope
	// attribute namespace of this PageContext
	setAttribute(OUT, out);

	return outs[depth];
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:21,代碼來源:PageContextImpl.java

示例4: writePrevious

import javax.servlet.jsp.JspWriter; //導入依賴的package包/類
/**
 * Write the specified text as the response to the writer associated with
 * the body content for the tag within which we are currently nested.
 *
 * @param pageContext The PageContext object for this page
 * @param text The text to be written
 *
 * @exception JspException if an input/output error occurs (already saved)
 */
public void writePrevious(PageContext pageContext, String text)
        throws JspException {

    JspWriter writer = pageContext.getOut();
    if (writer instanceof BodyContent) {
        writer = ((BodyContent) writer).getEnclosingWriter();
    }

    try {
        writer.print(text);

    } catch (IOException e) {
        TagUtils.getInstance().saveException(pageContext, e);
        throw new JspException
                (messages.getMessage("write.io", e.toString()));
    }

}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:28,代碼來源:TagUtils.java

示例5: doStartTag

import javax.servlet.jsp.JspWriter; //導入依賴的package包/類
/**
 * Process the start of this tag.
 *
 * @exception JspException if a JSP exception has occurred
 */
public int doStartTag() throws JspException {
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
    String serverName = (this.server == null) ? request.getServerName() : this.server;
    
    String baseTag =
        renderBaseElement(
            request.getScheme(),
            serverName,
            request.getServerPort(),
            request.getRequestURI());

    JspWriter out = pageContext.getOut();
    try {
        out.write(baseTag);
    } catch (IOException e) {
        pageContext.setAttribute(Globals.EXCEPTION_KEY, e, PageContext.REQUEST_SCOPE);
        throw new JspException(messages.getMessage("common.io", e.toString()));
    }
    
    return EVAL_BODY_INCLUDE;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:27,代碼來源:BaseTag.java

示例6: doEndTag

import javax.servlet.jsp.JspWriter; //導入依賴的package包/類
/** This concludes the html of the Form tag.
 * @throws JspException if any error occurs.
 * @return EVAL_PAGE if the JSP engine should continue evaluating the JSP page, otherwise return SKIP_PAGE.
 */
public int doEndTag() throws JspException {
    // Note: popping the nested component stack here causes runtime problems.
    try {
        JspWriter writer = pageContext.getOut();
        doEndTagExt1(writer);
        int i = super.doEndTag();
        doEndTagExt2(writer);
        return i;
    } catch (IOException e) {
        throw new JspException("error in FormTag: " + e);
    } finally {
        // Remove from stack
        CustomTag.popParent(this,pageContext);
    }
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:20,代碼來源:FormTag.java

示例7: perform

import javax.servlet.jsp.JspWriter; //導入依賴的package包/類
/** Looks up the request stream for input parameters and then generates appropriate metaData. */
public static void perform(HttpServletRequest request, JspWriter out, ServletContext servletContext) throws Exception {
    // Create a parameter Map from the input request
    Map<String, String> parameters = getParameters(request);
    if (log.isDebugEnabled())
        log.debug("Input: " + parameters);

    // Error out if parameters are not passed
    if (parameters == null) {
        String m = "MetaData cannot be generated since parameters have not been passed";
        log.error(m);
        throw new IllegalArgumentException(m);
    }

    // Obtain metaData
    String metaData = c_enableCaching ? obtainMetaData(parameters, servletContext) : generateMetaData(parameters, servletContext);
    out.print(metaData);
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:19,代碼來源:FinderMetaDataHelper.java

示例8: include

import javax.servlet.jsp.JspWriter; //導入依賴的package包/類
/**
 * Perform a RequestDispatcher.include() operation, with optional flushing
 * of the response beforehand.
 *
 * @param request The servlet request we are processing
 * @param response The servlet response we are processing
 * @param relativePath The relative path of the resource to be included
 * @param out The Writer to whom we are currently writing
 * @param flush Should we flush before the include is processed?
 *
 * @exception IOException if thrown by the included servlet
 * @exception ServletException if thrown by the included servlet
 */
public static void include(ServletRequest request,
                           ServletResponse response,
                           String relativePath,
                           JspWriter out,
                           boolean flush)
    throws IOException, ServletException {

    if (flush && !(out instanceof BodyContent))
        out.flush();

    // FIXME - It is tempting to use request.getRequestDispatcher() to
    // resolve a relative path directly, but Catalina currently does not
    // take into account whether the caller is inside a RequestDispatcher
    // include or not.  Whether Catalina *should* take that into account
    // is a spec issue currently under review.  In the mean time,
    // replicate Jasper's previous behavior

    String resourcePath = getContextRelativePath(request, relativePath);
    RequestDispatcher rd = request.getRequestDispatcher(resourcePath);

    rd.include(request,
               new ServletResponseWrapperInclude(response, out));

}
 
開發者ID:sunmingshuai,項目名稱:apache-tomcat-7.0.73-with-comment,代碼行數:38,代碼來源:JspRuntimeLibrary.java

示例9: writeTagBodyContent

import javax.servlet.jsp.JspWriter; //導入依賴的package包/類
/** This generates the HTML for the tag.
 * @param out The JspWriter object.
 * @param bodyContent The BodyContent object.
 * @throws IOException if any I/O error occurs.
 */
public void writeTagBodyContent(JspWriter out, BodyContent bodyContent) throws IOException {

    if (isFirstPass())
        // Write the main table tag, the table column headings, and start the table body
        out.println( getInitialHtml() );

    // Write out the start and end of the rows.
    out.println( getRowStartHtml() );
    if (m_hasRows)
        out.println( processRow());
    out.println( getRowEndingHtml() );

    // clear the body content for the next time through.
    bodyContent.clearBody();

    // Increment the RowNo
    ++m_rowNo;

    //Reset the column counters
    m_currColumnNo = 0;
    m_currColName = null;
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:28,代碼來源:GridTag.java

示例10: doEndTag

import javax.servlet.jsp.JspWriter; //導入依賴的package包/類
@Override
public int doEndTag() throws JspException {
    JspWriter out = pageContext.getOut();

    try {
        if (!"-1".equals(objectValue)) {
            out.print(objectValue);
        } else if (!"-1".equals(stringValue)) {
            out.print(stringValue);
        } else if (longValue != -1) {
            out.print(longValue);
        } else if (doubleValue != -1) {
            out.print(doubleValue);
        } else {
            out.print("-1");
        }
    } catch (IOException ex) {
        throw new JspTagException("IOException: " + ex.toString(), ex);
    }
    return super.doEndTag();
}
 
開發者ID:sunmingshuai,項目名稱:apache-tomcat-7.0.73-with-comment,代碼行數:22,代碼來源:ValuesTag.java

示例11: doStartTagInternal

import javax.servlet.jsp.JspWriter; //導入依賴的package包/類
@Override
protected int doStartTagInternal() throws Exception {
    try {
        String avatarUrl;
        String id = userId;
        String avatar = this.avatar;

        if (current || id == null) {
            DiscordUserDetails details = SecurityUtils.getCurrentUser();
            if (details != null) {
                id = details.getId();
                avatar = details.getAvatar();
            }
        }
        avatarUrl = AvatarType.USER.getUrl(id, avatar);
        JspWriter out = pageContext.getOut();
        out.write(avatarUrl);
    } catch (Exception ex) {
        throw new JspException(ex);
    }
    return SKIP_BODY;
}
 
開發者ID:GoldRenard,項目名稱:JuniperBotJ,代碼行數:23,代碼來源:AvatarTag.java

示例12: doStartTagInternal

import javax.servlet.jsp.JspWriter; //導入依賴的package包/類
@Override
protected int doStartTagInternal() throws Exception {
    try {
        String result = code;
        Long serverId = (Long) pageContext.getRequest().getAttribute("serverId");
        if (serverId != null) {
            Locale locale = (Locale) pageContext.getAttribute(LOCALE_ATTR);
            ApplicationContext context = getRequestContext().getWebApplicationContext();
            if (locale == null) {
                ContextService contextService = context.getBean(ContextService.class);
                locale = contextService.getLocale(serverId);
                pageContext.setAttribute(LOCALE_ATTR, locale);
            }
            result = context.getMessage(code, null, locale);
        }
        if (StringUtils.isNotEmpty(var)) {
            pageContext.setAttribute(var, result);
        } else {
            JspWriter out = pageContext.getOut();
            out.write(result);
        }
    } catch (Exception ex) {
        throw new JspException(ex);
    }
    return SKIP_BODY;
}
 
開發者ID:GoldRenard,項目名稱:JuniperBotJ,代碼行數:27,代碼來源:CommandTag.java

示例13: doAfterBody

import javax.servlet.jsp.JspWriter; //導入依賴的package包/類
/** .//GEN-BEGIN:doAfterbody
 *
 *
 * This method is called after the JSP engine processes the body content of the tag.
 * @return EVAL_BODY_AGAIN if the JSP engine should evaluate the tag body again, otherwise return SKIP_BODY.
 * This method is automatically generated. Do not modify this method.
 * Instead, modify the methods that this method calls.
 * @throws JspException
 * @throws JspException  */
public int doAfterBody() throws JspException, JspException {
    try {
        //
        // This code is generated for tags whose bodyContent is "JSP"
        //
        JspWriter out = getPreviousOut();
        BodyContent bodyContent = getBodyContent();

        writeTagBodyContent(out, bodyContent);
    } catch (Exception ex) {
        throw new JspException("error in FunctionGuardTag: " + ex);
    }

    if (theBodyShouldBeEvaluatedAgain()) {
        return EVAL_BODY_AGAIN;
    } else {
        return SKIP_BODY;
    }
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:29,代碼來源:FunctionGuardTag.java

示例14: doAfterBody

import javax.servlet.jsp.JspWriter; //導入依賴的package包/類
/** .//GEN-BEGIN:doAfterbody
 *
 *
 * This method is called after the JSP engine processes the body content of the tag.
 * @return EVAL_BODY_AGAIN if the JSP engine should evaluate the tag body again, otherwise return SKIP_BODY.
 * This method is automatically generated. Do not modify this method.
 * Instead, modify the methods that this method calls.
 * @throws JspException  */
public int doAfterBody() throws JspException {
    try {
        //
        // This code is generated for tags whose bodyContent is "JSP"
        //
        JspWriter out = getPreviousOut();
        BodyContent bodyContent = getBodyContent();

        writeTagBodyContent(out, bodyContent);
    } catch (Exception ex) {
        throw new JspException("error in ComponentGuardTag: " + ex);
    }

    if (theBodyShouldBeEvaluatedAgain()) {
        return EVAL_BODY_AGAIN;
    } else {
        return SKIP_BODY;
    }
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:28,代碼來源:ComponentGuardTag.java

示例15: otherDoEndTagOperations

import javax.servlet.jsp.JspWriter; //導入依賴的package包/類
/** The HTML is generated in this end tag, assuming the underlying field
 *  is not read-only or hidden
 */
public void otherDoEndTagOperations() throws JspException {
    
    super.otherDoEndTagOperations();
    
    if (getPropertyRuleIntrospector() == null ||
            (getPropertyRuleIntrospector() != null && !getPropertyRuleIntrospector().isHidden() && !getPropertyRuleIntrospector().isReadOnly() ) ) {
        
        try {
            JspWriter out = pageContext.getOut();
            out.println( getHtml() );
        } catch (IOException e) {
            String str = "Exception in writing the " + TAG_NAME;
            log.error(str, e);
            throw new JspWriteRuntimeException(str, e);
        }
    } else {
        log.debug(TAG_NAME + " Not displayed as field " + getField() + " is hidden or read-only");
    }
    
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:24,代碼來源:CalendarTag.java


注:本文中的javax.servlet.jsp.JspWriter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。