本文整理汇总了Java中javax.servlet.ServletInputStream.setReadListener方法的典型用法代码示例。如果您正苦于以下问题:Java ServletInputStream.setReadListener方法的具体用法?Java ServletInputStream.setReadListener怎么用?Java ServletInputStream.setReadListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.servlet.ServletInputStream
的用法示例。
在下文中一共展示了ServletInputStream.setReadListener方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInputStream
import javax.servlet.ServletInputStream; //导入方法依赖的package包/类
@Override
public ServletInputStream getInputStream() throws IOException {
final ServletInputStream inputStream = d.getInputStream();
return new ServletInputStream() {
@Override
public int read() throws IOException {
int b = inputStream.read();
if (b != -1) {
reqBody.write(b);
}
return b;
}
@Override
public void setReadListener(ReadListener readListener) {
inputStream.setReadListener(readListener);
}
@Override
public boolean isReady() {
return inputStream.isReady();
}
@Override
public boolean isFinished() {
return inputStream.isFinished();
}
};
}
示例2: processRequest
import javax.servlet.ServletInputStream; //导入方法依赖的package包/类
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter output = response.getWriter()) {
output.println("<html>");
output.println("<head>");
output.println("<title>Reading asynchronously</title>");
output.println("</head>");
output.println("<body>");
output.println("<h1>Reading asynchronously</h1>");
AsyncContext context = request.startAsync();
ServletInputStream input = request.getInputStream();
input.setReadListener(new ReadingListener(input, context));
output.println("</body>");
output.println("</html>");
}
}
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:20,代码来源:ReadingServlet.java