You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Alvin Antony <Al...@consol.de> on 2005/10/18 23:59:51 UTC

Java plugin 1.4.2 Cookie support URLConnection vs HttpClient

Hi Friends,
 
I am trying to use HttpClient mainly for File Upload from Applet.
 
When I use HttpClient for this I get Unauthorised Exception from an
authorised session, which I am not getting when I use the java
URLConnection instead of HttpClient.
 
As I understood Java plugin supports Cookie support for URLConnection as
shown here.
http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/cookie_
support.html
 
As there any way in htttpclient to use this option? 
 
Thanks a lot 
 
Alvin
 
alvin.antony@consol.de                     ConSol* Software GmbH
Phone +49-89-45841-191                     Consulting & Solutions
Fax   +49-89-45841-111                     Franziskanerstr. 38
Mobile+49-160-97340713
http://www.consol.de <http://www.consol.de/>
81669 München
 

Re: AW: Java plugin 1.4.2 Cookie support URLConnection vs HttpClient

Posted by Roland Weber <RO...@de.ibm.com>.
Hi Alvin,

> httpclient.getState().addCookie(
>   new Cookie("www.whatever.com", "jsession", "topsecret", 
>   "/", -1, false));

This should work, as long as you don't specify a different
HttpState when executing the method.

cheers,
  Roland

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


AW: Java plugin 1.4.2 Cookie support URLConnection vs HttpClient

Posted by Alvin Antony <Al...@consol.de>.
Hi Roland,

Thank you for the fast response.
The exception is from server, because I see on the response header that,
the server set a new jsession cookie on it. 

An another question, if I have a cookie parameter from browser via
javascript or what ever....

HttpClient httpclient = new HttpClient();
httpclient.getState().addCookie(
  new Cookie("www.whatever.com", "jsession", "topsecret", 
  "/", -1, false));
GetMethod httpget = new GetMethod("http://www.whatever.com");

Does this work for me? I found this in an old thread, or is there any
other way to set Cookie?

Thanks,

Alvin






alvin.antony@consol.de                     ConSol* Software GmbH
Phone +49-89-45841-191                     Consulting & Solutions
Fax   +49-89-45841-111                     Franziskanerstr. 38
Mobile+49-160-97340713
http://www.consol.de                       81669 München

-----Ursprüngliche Nachricht-----
Von: Roland Weber [mailto:ROLWEBER@de.ibm.com] 
Gesendet: Mittwoch, 19. Oktober 2005 07:53
An: HttpClient User Discussion
Betreff: Re: Java plugin 1.4.2 Cookie support URLConnection vs
HttpClient

Hi Alvin,

> As I understood Java plugin supports Cookie support for URLConnection
as
> shown here.
>
http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/cookie_
> support.html
> 
> As there any way in htttpclient to use this option? 

To make it short: No. HttpClient does in no way interact with the
Java Plug-in. You have to establish a new session with the server.
Maybe you can use some JavaScript to pass the required parameters
to the applet, for example the session cookie.
You did not mention where the UnauthorizedException occurs. If it
is on the server, the missing session cookie might be the reason.
If it happens on the client, the reason is the security model in
the browser environment. You have to sign the applet and the JARs
that hold HttpClient to permit some of the things HttpClient does
when initializing or opening a connection.

hope that helps,
  Roland

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Re: Java plugin 1.4.2 Cookie support URLConnection vs HttpClient

Posted by Roland Weber <RO...@de.ibm.com>.
Hi Alvin,

> As I understood Java plugin supports Cookie support for URLConnection as
> shown here.
> http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/cookie_
> support.html
> 
> As there any way in htttpclient to use this option? 

To make it short: No. HttpClient does in no way interact with the
Java Plug-in. You have to establish a new session with the server.
Maybe you can use some JavaScript to pass the required parameters
to the applet, for example the session cookie.
You did not mention where the UnauthorizedException occurs. If it
is on the server, the missing session cookie might be the reason.
If it happens on the client, the reason is the security model in
the browser environment. You have to sign the applet and the JARs
that hold HttpClient to permit some of the things HttpClient does
when initializing or opening a connection.

hope that helps,
  Roland

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org