在发送给客户端之前查看响应标头? [英] View response headers before they are sent to the client?
问题描述
有没有办法做到这一点?可以复制服务器要发送的内容吗?
我正在使用Eclipse Helios来开发具有POJO应用程序的JSP,并且正在使用运行在Debian Lenny上的Tomcat 5.5进行服务。
谢谢,
Ean
你可以使用 Filter
和 HttpServletResponseWrapper
。
覆盖三个 addXHeader(..)
方法,方法如下:
void addHeader(String name,String value){
super.addHeader(name,value);
getWriter()。write(name +:+ value);
}
然后,在过滤器
:
chain.doFilter(request,new HeaderHttpServletResponseWrapper(response));
但是我会使用Firebug来检查标题。
或看到这个问题(第二个答案)
I am writing a project for school. I want to be able to display, on a web page, the response headers that the web server sent to the client. I am able to read request headers from HttpServletRequest and am able to write response headers to HttpServletResponse no problem.
Is there any way to do this? It is possible to make a copy of what the server is about to send?
I am using Eclipse Helios to develop this JSP with POJOs application, and am using Tomcat 5.5 running on Debian Lenny to serve it.
Thanks,
Ean
You can use a Filter
and an HttpServletResponseWrapper
.
Override the three addXHeader(..)
methods with something like:
void addHeader(String name, String value) {
super.addHeader(name, value);
getWriter().write(name + " : " + value);
}
And then, in a Filter
:
chain.doFilter(request, new HeaderHttpServletResponseWrapper(response));
But I would use Firebug to check headers.
Or see this question (the 2nd answer)
这篇关于在发送给客户端之前查看响应标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!