Mike Haberman wrote:
>
> for a little more information. I am processing header values of one
> http header and creating a new header with the same values (writing a
> proxy). I would like to avoid calling addCookie() since that would involve
> looking at each header value and then parsing the cookie string, creating a
> cookie and then calling addCookie(); Also, there might be multiple
> non-cookie values that need to be added to the header.
Can you clarify more please? The header does not contain multiple
entries for multiple cookies. All the cookies are contained in a single
header string containing all the name/value pairs. If you're creating a
new header with the same values as the old header, then just get the
value of the request header with the name "Cookie" and add that value to
the new header using the name "Cookie" (or "Set-Cookie", depending on
what you are doing). It shouldn't matter that the value might represent
multiple cookies.
Here's some code I wrote in a servlet to see the value of the headers:
out.println("Header Parameters:");
Enumeration enum = req.getHeaderNames();
while (enum.hasMoreElements()) {
String name = (String) enum.nextElement();
String value = req.getHeader(name);
out.println(name + ": " + value);
}
Using this code, the name is reported as "COOKIE", the value is a
semicolon separated string of the name value pairs of all the cookies.
To use this in a new header in a request, I would simply call
request.addHeader(name, value). If you are really putting it into a
response, then the name is "Set-Cookie": so, to show it literally:
response.setHeader("Set-Cookie", "name1=value1; name2=value2;
name3=value3");
KMukhar
___________________________________________________________________________
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