Como funciona o getHeaderNames

boa noite…

eu queria saber como que funciona o método getHeaderNames() e o método getHeaders(String)??
e como usa-los??

aguardo a resposta…

Já deu uma olhada na API?

java.util.Enumeration
getHeaderNames()
The default behavior of this method is to return getHeaderNames() on the wrapped request object.

getHeader

public java.lang.String getHeader(java.lang.String name)

Returns the value of the specified request header as a String. If the request did not include a header of the specified name, this method returns null. If there are multiple headers with the same name, this method returns the first head in the request. The header name is case insensitive. You can use this method with any request header.

Parameters:
    name - a String specifying the header name
Returns:
    a String containing the value of the requested header, or null if the request does not have a header of that name

java.util.Enumeration
getHeaders(java.lang.String name)
The default behavior of this method is to return getHeaders(String name) on the wrapped request object.

getHeaders

public java.util.Enumeration getHeaders(java.lang.String name)

Returns all the values of the specified request header as an Enumeration of String objects.

Some headers, such as Accept-Language can be sent by clients as several headers each with a different value rather than sending the header as a comma separated list.

If the request did not include any headers of the specified name, this method returns an empty Enumeration. The header name is case insensitive. You can use this method with any request header.

Parameters:
    name - a String specifying the header name
Returns:
    an Enumeration containing the values of the requested header. If the request does not have any headers of that name return an empty enumeration. If the container does not allow access to header information, return null

Well, it is that simple, this is java basics, and is based on the simple exanple that is provided in the Java API Documentation, for java.util.Enumeration. I strongly suggestion to read it when you have some time.

for (Enumeration enum=request.getHeaderNames(); enum.hasMoreElements():wink: {
String headerName = (String)enum.nextElement();
System.out.println("Name = " + headerName);
}

Remember, that HttpServletRequest is an interface, so you don’t have to worry about the implementation, otherwise if you decide to switch to another Servlet Container, then you will not be able to do that…
That’s why they are called interfaces.

Exemplo getHeaders(): http://www.exampledepot.com/egs/javax.servlet/GetHeaders.html

o problema dessa api…
é que como eu to começando eu não manjo bem no inglês
por isso a minha pergunta…
mas se alguem puder me falar meio resumido a função desses métodos eu agradeço…