>>> David Gowe <[EMAIL PROTECTED]> 09-Nov-00 4:10:57 PM >>>
>Is it possible to set user defined headers in the HTTP
>Header using the response.setHeader() method? If yes,
>what is the mechanism to do it.
>I have tried to set
>response.setHeader("Authorization","Basic www");
That's how you do it.
>but when I check with the request using
>request.getHeaderNames() in the forwarded servlet, it
>does not figure among the list of header fields.
But how are the headers you set on the response supposed to be set on
the request? Duh!
If you want to set headers on the request (for example to fool a
servlet into thinking something about the request that isn't actually
true) then you can't do it.
Yet.
The new revision of the Servlet API - 2.3 - will allow you to do this
by overridding the request object that a servlet recieves - you would
do something like this in such a request object:
public String getHeader(String name)
{
if(name.equals("Authorization"))
return "Basic www"
return super.getHeader(name);
}
This is quite neat... you can also do it in remarkably configurable
ways... by using filters on the request. Filters can be specified in
the web.xml file that you deliver with your WAR.
Nic Ferrier
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html