帮忙看看这个程序怎么回事?

geniusjava 2003-04-29 12:59:46
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Buffering extends HttpServlet {
public void doGet(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException {
res.setContentType("text/html");
res.setBufferSize(8*1024);
PrintWriter out=res.getWriter();
int size=res.getBufferSize();
log("The default buffer size is "+size);
out.println("The client won't see this");//这里为什么在屏幕上看不到呢?
res.reset();
out.println("Nor will the client see this!");//这里为什么在屏幕上看不到呢?

res.reset();
out.println("And this won't be seen if sendError() is called");
if(req.getParameter("important_parameter")==null) {
res.sendError(res.SC_BAD_REQUEST, "important_parameter needed");
}
}
}
...全文
42 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
geniusjava 2003-04-29
  • 打赏
  • 举报
回复
你们上面说的我都试了,可是还是看不到呀?
怎么回事呀?
老土豆T 2003-04-29
  • 打赏
  • 举报
回复
Dos 历史System.out.print

这里的out 是HttpServlet PrintWriter=res.getWrtiter();

输出到页面
老土豆T 2003-04-29
  • 打赏
  • 举报
回复
PrintWriter out=res.getWriter();
out.println("Nor will the client see this!");
就可以看到了。

res.reset();将清空response对象里的数据。
struggle007csdn 2003-04-29
  • 打赏
  • 举报
回复
看看是不是输出到服务器(比如TOMCAT)的DOS界面里了。
sikuan 2003-04-29
  • 打赏
  • 举报
回复
out.println("The client won't see this");//这里为什么在屏幕上看不到呢?
res.reset();//this is the reason
out.println("Nor will the client see this!");//这里为什么在屏幕上看不到呢?

res.reset();//this is the reason

public void reset() Clears any data that exists in the buffer as well as the status code and headers

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧