You can. In this case the domain attribute must match the host one to one.

Oleg


>-- Original Message --
>Reply-To: "Jakarta Commons Users List" <[EMAIL PROTECTED]>
>Reply-To: <[EMAIL PROTECTED]>
>From: Jos� Gustavo Zagato <[EMAIL PROTECTED]>
>To: "'Jakarta Commons Users List'" <[EMAIL PROTECTED]>
>Subject: RE: HttpClient Header Problem
>Date: Thu, 23 Oct 2003 11:02:12 -0300
>
>
>Thanks !
>
>       So I can't use the localhost or my Machine IP address as host ?
>
>Cheers !
>
>  Jos� Gustavo Zagato Rosa
>System Analyst - Atos Origin
>[EMAIL PROTECTED]
>
>
>-----Original Message-----
>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
>Sent: quinta-feira, 23 de outubro de 2003 09:57
>To: Jakarta Commons Users List
>Subject: RE: HttpClient Header Problem
>
>We do not have any sample code because we never thought it would be of
>any
>difficulty. 
>
>Try this line
>
>initialState.addCookie(new Cookie(domain, "JSESSIONID", sessionId, "/",
>null,
>false));
>
>The only diffucult part here is the domain attribute. If your target
>host
>is, for example, 'myhost.whatever.com', valid domain would be
>'.whatever.com'
>
>Oleg
>
>>-- Original Message --
>>Reply-To: "Jakarta Commons Users List"
><[EMAIL PROTECTED]>
>>Reply-To: <[EMAIL PROTECTED]>
>>From: Jos� Gustavo Zagato <[EMAIL PROTECTED]>
>>To: "'Jakarta Commons Users List'" <[EMAIL PROTECTED]>
>>Subject: RE: HttpClient Header Problem
>>Date: Thu, 23 Oct 2003 10:29:22 -0300
>>
>>
>>Hi ! 
>>
>>      Thanks for the answer !
>>      This is the piece of code with Im trying to run, Can you
>>anything else wrong ? If you have any piece of code with this
>>httpSate.addcookie please send to me !
>>
>>public String doRequest(String server, String sessionId, String domain)
>>{
>>
>>              
>>              HttpClient client = new HttpClient();
>>              
>>              HttpState initialState = new HttpState();
>>      
>>initialState.setCookiePolicy(CookiePolicy.COMPATIBILITY);
>>
>>              HttpMethod method = new GetMethod(server);
>>
>>              try {
>>
>>                      //Cookie jSession = new
>>Cookie(domain,"Cookie","JSESSIONID="+sessionId);
>>                      //CookieSpecBase cookspec = new
>>CookieSpecBase(); 
>>
>>                      //Header hd =
>>cookspec.formatCookieHeader(jSession);
>>                      //
>>method.addRequestHeader(hd);
>>                      method.addRequestHeader("Cookie", "JSESSIONID="
>>+ sessionId);
>>
>>                      requestCode = client.executeMethod(method);
>>
>>                      Cookie[] cookies =
>>client.getState().getCookies();
>>                      // Display the cookies
>>                      System.out.println("Return: " + requestCode);
>>                      System.out.println("Present cookies: ");
>>                      for (int i = 0; i < cookies.length; i++) {
>>                              System.out.println(" - " +
>>cookies[i].toExternalForm());
>>                      }
>>
>>              } catch (Exception e) {
>>                      e.printStackTrace();
>>
>>              } catch (Throwable tre) {
>>                      tre.printStackTrace();
>>              }
>>
>>              byte[] responseBody = method.getResponseBody();
>>
>>              return new String(responseBody);
>>
>>      }
>>
>>Regards !
>>
>>  Jos� Gustavo Zagato Rosa
>>System Analyst - Atos Origin
>>[EMAIL PROTECTED]
>>
>>
>>-----Original Message-----
>>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
>>Sent: quinta-feira, 23 de outubro de 2003 09:13
>>To: Jakarta Commons Users List
>>Subject: RE: HttpClient Header Problem
>>
>>Hi Jos�,
>>
>>Simply use HttpState#addCookie method to add a cookie to the HTTP
>>session.
>>Currently HttpClient overwrites manually set 'Cookie' headers. You are
>>not
>>the first one to have fallen into this trap. Quite a few people
>>complained
>>about what they see as disappearance of manually set 'Cookie' headers.
>I
>>am planning to provide a patch against CVS HEAD soon. The fix, however,
>>is
>>not likely to make it into our stable 2.0 branch, so I strongly
>>encourage
>>to use HttpState class to handle cookies.
>>
>>Cheers
>>
>>Oleg
>>
>>
>>>-- Original Message --
>>>Reply-To: "Jakarta Commons Users List"
>><[EMAIL PROTECTED]>
>>>Reply-To: <[EMAIL PROTECTED]>
>>>From: Jos� Gustavo Zagato <[EMAIL PROTECTED]>
>>>To: "'Jakarta Commons Users List'" <[EMAIL PROTECTED]>
>>>Subject: HttpClient Header Problem
>>>Date: Thu, 23 Oct 2003 08:44:37 -0300
>>>
>>>
>>>Hi Folks !
>>> 
>>>      I'm trying to develop an applet with uses the commons httpclient
>>>to interact with a struts action. I developed a few examples and it
>>>worked fine, but now I need to somehow make the applet "join" the http
>>>session started by the browser with loaded the applet. I tried to add
>a
>>>Cookie to the request with contains the session id. In another shot I
>>>tried to add a new header entry with contains the session id.
>>>Unfortunately all shots went to wrong directions.
>>> 
>>>      So does anyone here has a example on how to add a new header
>>entry
>>>to a http get request ? There is any thing special that I need to do
>to
>>>"join" a already started session ? How deep is the rabbit hole ?
>>> 
>>>Cheers !
>>> 
>>>  Jos� Gustavo Zagato Rosa
>>>System Analyst - Atos Origin
>>>[EMAIL PROTECTED]
>>> 
>>> 
>>> 
>>>  Jos� Gustavo Zagato Rosa
>>>System Analyst - Atos Origin
>>>[EMAIL PROTECTED]
>>> 
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to