當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。