本文整理匯總了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());
}