wood burning stoves*
The moose likes Servlets and the fly likes Setting HTTP headers. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Setting HTTP headers." Watch "Setting HTTP headers." New topic
Author

Setting HTTP headers.

Miro Mile
Greenhorn

Joined: Dec 19, 2003
Posts: 5
Hi,
I have the following piece of code:

So I set the headers commented as 1 and 2. The first one - Refresh - works prefectly. The second one - Expires, doesn't get set, the req.getHeader (3) returns null.
I also tried setting it up with the setHeader method, using a String with a date format copied from the RFC - 'Thu, 01 Dec 1994 16:00:00 GMT'. Again, no result.
And there is one more thing - charset set with setContentType works perfectly. Although when I want to change the 'accept-charset' using the setHeader, nothing happens.
I am working on Tomcat 5.0.16.
Well, I'd be grateful for pointing out what is the problem. Why some headers (Refresh) get set, while the other (ex. Expires, Accept-Charset) don't.
rgds.
miro.


rgds,<br />miro.
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292

This seems more like a straightforward Serlvets question than a Certification question, so I will move it appropriately.


Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
It looks a lot as if you are setting headers in the response, and somehow expecting those headers to appear in the request. They are quite different things. Request headers are information sent from the browser for use by the server. Response headers are information sent from the server for use by the browser. Why would you expect them to be the same?


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Miro Mile
Greenhorn

Joined: Dec 19, 2003
Posts: 5

Request headers are information sent from the browser for use by the server. Response headers are information sent from the server for use by the browser. Why would you expect them to be the same?

You're right, it doesn't make much sense. And thanks for your answer - everything is clear right now.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Setting HTTP headers.
 
Similar Threads
unable to compile servlet
Code Review - ChatServlet
Servlet question -standalone
Session problem
Doubt in reDirect and post