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