本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
}
}
示例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;
}
示例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;
}
}
}
示例7: doTag
import javax.servlet.jsp.JspWriter; //导入方法依赖的package包/类
@Override
public void doTag() throws JspException, IOException {
JspWriter out = getJspContext().getOut();
out.write(getEscapedValue());
}