当前位置: 首页>>代码示例>>Java>>正文


Java JspWriter.write方法代码示例

本文整理汇总了Java中javax.servlet.jsp.JspWriter.write方法的典型用法代码示例。如果您正苦于以下问题:Java JspWriter.write方法的具体用法?Java JspWriter.write怎么用?Java JspWriter.write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.servlet.jsp.JspWriter的用法示例。


在下文中一共展示了JspWriter.write方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: output

import javax.servlet.jsp.JspWriter; //导入方法依赖的package包/类
public static boolean output(JspWriter out, Object input, String value,
        String defaultValue, boolean escapeXml) throws IOException {
    if (input instanceof Reader) {
        char[] buffer = new char[8096];
        int read = 0;
        while (read != -1) {
            read = ((Reader) input).read(buffer);
            if (read != -1) {
                if (escapeXml) {
                    String escaped = Util.escapeXml(buffer, read);
                    if (escaped == null) {
                        out.write(buffer, 0, read);
                    } else {
                        out.print(escaped);
                    }
                } else {
                    out.write(buffer, 0, read);
                }
            }
        }
        return true;
    } else {
        String v = value != null ? value : defaultValue;
        if (v != null) {
            if(escapeXml){
                v = Util.escapeXml(v);
            }
            out.write(v);
            return true;
        } else {
            return false;
        }
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:35,代码来源:Out.java

示例5: doAfterBody

import javax.servlet.jsp.JspWriter; //导入方法依赖的package包/类
/**
 * Performs the replacement.
 */
public int doAfterBody() throws JspTagException
{
    String contentString = this.bodyContent.getString();
    StringBuffer contentBuffer = new StringBuffer(contentString);

    int beginIndex = -1;
    int targetLength = this.target.length();

    // while instances of target still exist
    while ((beginIndex = contentString.indexOf(this.target)) > -1) {

        int endIndex = beginIndex + targetLength;
        contentBuffer.replace(beginIndex, endIndex, this.replacement);

        contentString = contentBuffer.toString();
    }

    // write out the changed body
    JspWriter pageWriter = this.bodyContent.getEnclosingWriter();
    try {

        pageWriter.write(contentString);

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

    return SKIP_BODY;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:33,代码来源:SampleBodyTag.java

示例6: output

import javax.servlet.jsp.JspWriter; //导入方法依赖的package包/类
public static boolean output(JspWriter out, Object input, String value, String defaultValue, boolean escapeXml)
		throws IOException {
	if (input instanceof Reader) {
		char[] buffer = new char[8096];
		int read = 0;
		while (read != -1) {
			read = ((Reader) input).read(buffer);
			if (read != -1) {
				if (escapeXml) {
					String escaped = Util.escapeXml(buffer, read);
					if (escaped == null) {
						out.write(buffer, 0, read);
					} else {
						out.print(escaped);
					}
				} else {
					out.write(buffer, 0, read);
				}
			}
		}
		return true;
	} else {
		String v = value != null ? value : defaultValue;
		if (v != null) {
			if (escapeXml) {
				v = Util.escapeXml(v);
			}
			out.write(v);
			return true;
		} else {
			return false;
		}
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:35,代码来源:Out.java

示例7: doTag

import javax.servlet.jsp.JspWriter; //导入方法依赖的package包/类
@Override
public void doTag() throws JspException, IOException {
	JspWriter out = getJspContext().getOut();
	out.write(getEscapedValue());
}
 
开发者ID:kalsowerus,项目名称:Guestbook9001,代码行数:6,代码来源:EscapeTag.java


注:本文中的javax.servlet.jsp.JspWriter.write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。