File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Urgent! use setHeader will not work for my proxy server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Urgent! use setHeader will not work for my proxy server" Watch "Urgent! use setHeader will not work for my proxy server" New topic
Author

Urgent! use setHeader will not work for my proxy server

Stephen Wei
Ranch Hand

Joined: Oct 09, 2001
Posts: 73
Hello all:
I am having big trouble with the firewall proxy server. My system seems to be working ok when the proxy server is disabled. Can someone please help??!!!
I know proxy server tends to cache the pages and replay them, I do not want this feature. So I used the following code: but it will not work, why?
For all JSP page I am working: I add
( I do not need to set the header on the HTML part of the JSP page right?)
<HTML>
<%@ page session="true" %>
<%
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Pragma", "no-cache");
%>
<HTML>
for all html page, I add
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
But my system is still not working well with the proxy (seems like some problem with the session). When I disable proxy, it works ok. What did I do wrong? For setting the header, is there a restriction on where I put the setHeader code? (Like between <Head> , or <Body>??)
I am so confused, can someone help?
Thanks


Sun Certified Programmer for Java Platform
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

well.. the headers cannot be set after the response buffer is flushed, so make sure your response.setHeader() calls are *among the first* things you do on your JSP.

Regarding the whole META tag no-cache thing. This is a perennial topic at the Ranch. MANY people seem to have trouble with caching, and I suspect it's because browsers and browser *versions* all implement caching in a (at least somewhat) broken way. Then you add on the proxy, which may have 'slightly broken' caching. And to top it off, perhaps your webserver is doing something odd.

Regarding session trouble: does your webproxy filter out cookies? sessions require a cookie, unless you've enabled URL Rewriting.
[ February 11, 2002: Message edited by: Mike Curwen ]
Stephen Wei
Ranch Hand

Joined: Oct 09, 2001
Posts: 73
Hello: Thanks for the answer.
As you mentioned, there are many possible causes. Now my problem is that I do not konw which one is causing the trouble, proxy, cache, or my tomcat server.
But I find that when I disable the proxy server to use the system, it seems to be working fine, and I think the proxy is using cookies.
It is a intranet system, so I wonder if I can ask my client to disable the proxy while using the system?? maybe I should try to talk to my client if I can not figure out what is going wrong..
 
Don't get me started about those stupid light bulbs.
 
subject: Urgent! use setHeader will not work for my proxy server
 
Similar Threads
encoding problem, please help
Refreshing pages
Caching is not working
Cache Control
How to control Caching in JBoss