本文整理汇总了Java中javax.servlet.jsp.PageContext.getOut方法的典型用法代码示例。如果您正苦于以下问题:Java PageContext.getOut方法的具体用法?Java PageContext.getOut怎么用?Java PageContext.getOut使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.servlet.jsp.PageContext
的用法示例。
在下文中一共展示了PageContext.getOut方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
import javax.servlet.jsp.PageContext; //导入方法依赖的package包/类
/**
* Write the specified text as the response to the writer associated with
* this page. <strong>WARNING</strong> - If you are writing body content
* from the <code>doAfterBody()</code> method of a custom tag class that
* implements <code>BodyTag</code>, you should be calling
* <code>writePrevious()</code> instead.
*
* @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 write(PageContext pageContext, String text)
throws JspException {
JspWriter writer = pageContext.getOut();
try {
writer.print(text);
} catch (IOException e) {
TagUtils.getInstance().saveException(pageContext, e);
throw new JspException
(messages.getMessage("write.io", e.toString()));
}
}
示例2: writePrevious
import javax.servlet.jsp.PageContext; //导入方法依赖的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()));
}
}
示例3: doGet
import javax.servlet.jsp.PageContext; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
PageContext pageContext = JspFactory.getDefaultFactory().getPageContext(
this, req, resp, null, false, JspWriter.DEFAULT_BUFFER, true);
JspWriter out = pageContext.getOut();
if (Constants.DEFAULT_BUFFER_SIZE == out.getBufferSize()) {
resp.getWriter().println("OK");
} else {
resp.getWriter().println("FAIL");
}
}