views:

98

answers:

2

I have a piece of Java code which tries to access the header information posted by an html page.Right now I don't have the html page but I need to access the header information in the java file details.Can anyone please help me in writing a html page which sets header information?

A: 

Headers cannot be changed by a plain html file.

What you are trying to achieve though may be doable via "meta http-equiv" directives. So, what are you trying to achieve?

cherouvim
meta http-equiv is ok.Is there any syntax?
Harish
A: 

Since you tagged it javascript: Use an AJAX request. You can use the setRequestHeader(header, value) method of XMLHttpRequest

var xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.setRequestHeader("HeaderName", "value");
xhr.onreadystatechange = function(){};
xhr.send();
Amarghosh
I can't use AJAX.I want only synchronous Javascript.
Harish
You can make the xhr synchronous by calling the `open` with the third parameter (async) set to `false`. https://developer.mozilla.org/en/XMLHttpRequest#open%28%29
Amarghosh