当前位置: 首页>>代码示例>>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;未经允许,请勿转载。