本文整理汇总了Java中javax.servlet.AsyncContext.getResponse方法的典型用法代码示例。如果您正苦于以下问题:Java AsyncContext.getResponse方法的具体用法?Java AsyncContext.getResponse怎么用?Java AsyncContext.getResponse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.servlet.AsyncContext
的用法示例。
在下文中一共展示了AsyncContext.getResponse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeStock
import javax.servlet.AsyncContext; //导入方法依赖的package包/类
public void writeStock(AsyncContext actx, Stock stock) {
HttpServletResponse response = (HttpServletResponse)actx.getResponse();
try {
PrintWriter writer = response.getWriter();
writer.write("STOCK#");//make client parsing easier
writer.write(stock.getSymbol());
writer.write("#");
writer.write(stock.getValueAsString());
writer.write("#");
writer.write(stock.getLastChangeAsString());
writer.write("#");
writer.write(String.valueOf(stock.getCnt()));
writer.write("\n");
writer.flush();
response.flushBuffer();
}catch (IOException x) {
try {actx.complete();}catch (Exception ignore){/* Ignore */}
}
}
示例2: ContextWrapper
import javax.servlet.AsyncContext; //导入方法依赖的package包/类
public ContextWrapper(AsyncContext context) {
this.context = context;
this.request = (HttpServletRequest) context.getRequest();
this.response = (HttpServletResponse) context.getResponse();
setTimeout(10000);
}