You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Srinivas Velidanda <sv...@yahoo.com> on 2004/10/08 08:43:24 UTC

HttpClient with Applet to upload files using MultipartPost is required....

Hi,
 
I got a sample signed applet working that is given at the links you specified.
but need help using it with HttpClient...
 
Pl let me know if somebody already worked with applet using HttpClient.
 
thanks.
Srinivas.

Roland Weber <RO...@de.ibm.com> wrote:
Hello Srinivas,

java.sun.com seems to be down or overloaded, but
I found this link in Google about signed applets:

http://www.betrusted.com/downloads/products/keytools/v51/pro/j-docs/html/SampleCodes/sampleApplet/codesign/intro.html

Once java.sun.com is back up, these links could be useful for you:
http://java.sun.com/developer/onlineTraining/Programming/JDCBook/signed.html
http://java.sun.com/security/signExample12/

hope that helps,
Roland





Srinivas Velidanda 
07.10.2004 15:33
Please respond to
"Commons HttpClient Project"


To
commons-httpclient-dev@jakarta.apache.org
cc

Subject
Re: HttpClient query...






Hi,

Greetings.

I am running into problems, as you have mentioned, i was trying to work 
with an Applet. Couldn't set security permissions and even if I set the 
permissions there could be problems with setting the user credentials.

I do not know how I can make the applet access the files at client side.

So, pl let me know how can I create a multipart request using HttpClient 
api or 

--how can I read the files from the file system once I get the drive and 
directory names from the client by using javascript, I searched the 
internet but couldn't find any samples to generate html form using 
javascript and that must create file items dynamically by reading the 
files from the file system.

I thought of all the options that I could, but not getting a solution, 
which is very urgent.

Pl. suggest me a solution.

thanks for the help,

Srinivas. 

Roland Weber wrote:
Hello Srinivas,

I think some people have succeeded in using HttpClient from
an applet. Remember you will have to sign the applet in order
to access the client file system. But you could run into problems
accessing the user credentials in the applet.

You could also try to write JavaScript code which generates
an HTML form, including one file element for every file in the
directory. In that case, the browser would take care of building
the HTTP request and adding user credentials. The problem
once more is to access the file system from the script code.

Using a combination of both could work out. It is possible to
call JavaScript from an applet and vice versa. So you could
write (and sign!) an applet that creates a directory listing, then
use that listing in JavaScript to create a form which is then
posted by the browser to the server.

Other ideas?

cheers,
Roland




Srinivas Velidanda 
06.10.2004 13:43
Please respond to
"Commons HttpClient Project"


To
commons-httpclient-dev@jakarta.apache.org
cc

Subject
Re: HttpClient query...






Hi,

Thanks for your help.

I found the samples specified by you very much useful.

I got it working with my JSP by sending user credential parameters which 
were required at my server.

Now the problem is making the same with an applet as it is not working 
from remote client accessing the JSP.

The flow is like this.

I have a screen where I enter drive name, and directory to be uploaded and 

in the next JSP I get the files of specified folder and create multipart 
request and send to the server along with User credentials.

Everything is working fine on the system which both client and server are 
running. But If I try the same from remote client then It is looking for 
files in the folder specified by client in server which is generating null 

pointer exception.

Now I need to make the functionality of creating the multipart request at 
client side, I am planning to do it in the applet.

Is it the right way to go for an applet, or can you suggest me some other 
solution..

thanks,
Srinivas.

Roland Weber wrote:
Hello Srinivas,

you are using HttpClient from within a JSP to connect to
the server that is running the JSP? Or to a different server?

If you want to set request parameters, you don't do that
before creating the multipart request. You create the
multipart request, then add the parameters using
MP.addParameter(..) or MP.addPart(...).
Just make sure to add all required parameters before
you *execute* the method. See also the web site at

http://jakarta.apache.org/commons/httpclient/methods/multipartpost.html

The sample code for multipart file upload is for the
2.0 API, but it should be helpful anyway. Go straight
to the "actionPerformed" method:

http://cvs.apache.org/viewcvs.cgi/jakarta-commons/httpclient/src/examples/?only_with_tag=HTTPCLIENT_2_0_BRANCH



cheers,
Roland





Srinivas Velidanda 
05.10.2004 14:00
Please respond to
"Commons HttpClient Project"


To
Commons HttpClient Project 
cc

Subject
Re: HttpClient query...






Hi Roland, 
thanks for the reply.

I am new to this API and pl let me know how can I do the following.

1. can I set the same parameters coming from the session before creating 
Multipart request to the Multipart request, if yes, how can I set and how 
can these parameters can be referred at the server side.

2.I am getting the session parameters in the JSP where I am creating 
Multipart request, but once I post the Multipart request to the server the 


session is getting killed.

We are not working with cookies.

Is there a solution without using cookies or I must go for cookies..

thanks,

Srinivas

Roland Weber wrote:
Hello Srinivas,

if the session is handled by a session cookie, just make sure
you use the same HttpState object for all requests. That should
happen automagically if you do nothing special and re-use one
HttpClient for all requests.

If the server uses URL rewriting because it believes that the
client can't handle cookies, you have a problem. You will have
to parse server responses in order to extract URLs with the
session information encoded in them. Or convince the server
to send cookies.

hope that helps,
Roland





Srinivas Velidanda 
05.10.2004 13:32
Please respond to
"Commons HttpClient Project"


To
commons-httpclient-dev@jakarta.apache.org
cc

Subject
HttpClient query...






Hi,

I am using HttpClient (commons-httpclient-3.0-alpha2) api for file upload.

How to handle a session if I am creating a MultipartPost request in a JSP 
and posting the request using client.executeMethod(mPost) to a servlet 
URL. 

Once I send the request the session is getting killed and could not pass 
on the request to a specific handler in sequence..

Pl. let me know how to handle the session, if possible send me some sample 



code for that.

thanks in advance..

Srinivas.



---------------------------------
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!


---------------------------------
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.



---------------------------------
Do you Yahoo!?
vote.yahoo.com - Register online to vote today!


---------------------------------
Do you Yahoo!?
vote.yahoo.com - Register online to vote today!

		
---------------------------------
Do you Yahoo!?
vote.yahoo.com - Register online to vote today!

Re: HttpClient with Applet to upload files using MultipartPost is required....

Posted by Adrian Sutton <ad...@intencha.com>.
Hi Srinivas,
Sorry for the delay in getting back to you.  There really is nothing 
different about using HttpClient in an applet compared to an 
application.  I suggest you first get HttpClient working for you in a 
standalone application and then move it into an applet.

If you have trouble getting HttpClient to work in an application please 
post the code you're using and if possible the debug log (see 
http://jakarta.apache.org/commons/httpclient/logging.html ).

Regards,

Adrian Sutton.

On 08/10/2004, at 7:01 PM, Srinivas Velidanda wrote:

> Hi Adrian Sutton,
>
> thanks for the mail.
>
> I need some help regarding using Applet with HttpClient.
>
> I am able to make the signed applet get opened in the Internet 
> Explorer, but I got stuck up
>
> 1. couldn't grant permissions to read a particular folder at client 
> side.
> 2. Even If I do that I am not clear with pass the multipart request 
> created in the applet to
>     the servlet.
>
> I have been working with it since 1 week but couldn't find the right 
> solution.
> As far as I know applet can communicate to the servlet using the 
> URLConnection, URLEncoder ....
>
> but how can I make the MultiparPost request linked to the request from 
> applet.
>
> Pl. suggest me a solution.,
>
> thank you,
> Srinivas.
>
>
>
> Adrian Sutton <ad...@intencha.com> wrote:
>
> On 08/10/2004, at 5:21 PM, Srinivas Velidanda wrote:
>
>> Hi,
>>
>> can I get the sample java code to make the signed applet with
>> HttpClient.
>
> No unfortunately we develop a commercial product so I can't release the
> code. However, the usage of HttpClient is exactly the same in an
> applet as an application. You do however need to make sure the applet
> is signed and that you are using at least Java 1.3 (ie: you can't be
> using the Microsoft JVM that is the default in Windows IE). When you
> load the applet it should bring up a security dialog asking if you want
> to give the applet permission to run, click yes and you have full
> permissions.
>
> If you don't see that dialog then the applet isn't correctly signed.
>
>> thanks,
>> Srinivas.
>
> Regards,
>
> Adrian Sutton
>
> ----------------------------------------------
> Intencha "tomorrow's technology today"
> Ph: 3420 4584 0422236329
> 35 Prenzler St
> Upper Mount Gravatt 4122
> Australia QLD
> www.intencha.com
>
>
>> ATTACHMENT part 2 application/pgp-signature x-mac-type=70674453; 
>> name=PGP.sig
>
> 		
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Mail - You care about security. So do we.
----------------------------------------------
Intencha "tomorrow's technology today"
Ph: 3420 4584 0422236329
35 Prenzler St
Upper Mount Gravatt 4122
Australia QLD
www.intencha.com

Re: HttpClient with Applet to upload files using MultipartPost is required....

Posted by Srinivas Velidanda <sv...@yahoo.com>.
Hi Adrian Sutton,
 
thanks for the mail.
 
I need some help regarding using Applet with HttpClient.
 
I am able to make the signed applet get opened in the Internet Explorer, but I got stuck up 
 
1. couldn't grant permissions to read a particular folder at client side.
2. Even If I do that I am not clear with pass the multipart request created in the applet to 
    the servlet.
 
I have been working with it since 1 week but couldn't find the right solution.
As far as I know applet can communicate to the servlet using the URLConnection, URLEncoder ....
 
but how can I make the MultiparPost request linked to the request from applet.
 
Pl. suggest me a solution.,
 
thank you,
Srinivas.
 
 
 
Adrian Sutton <ad...@intencha.com> wrote:

On 08/10/2004, at 5:21 PM, Srinivas Velidanda wrote:

> Hi,
>
> can I get the sample java code to make the signed applet with 
> HttpClient.

No unfortunately we develop a commercial product so I can't release the 
code. However, the usage of HttpClient is exactly the same in an 
applet as an application. You do however need to make sure the applet 
is signed and that you are using at least Java 1.3 (ie: you can't be 
using the Microsoft JVM that is the default in Windows IE). When you 
load the applet it should bring up a security dialog asking if you want 
to give the applet permission to run, click yes and you have full 
permissions.

If you don't see that dialog then the applet isn't correctly signed.

> thanks,
> Srinivas.

Regards,

Adrian Sutton

----------------------------------------------
Intencha "tomorrow's technology today"
Ph: 3420 4584 0422236329
35 Prenzler St
Upper Mount Gravatt 4122
Australia QLD
www.intencha.com


> ATTACHMENT part 2 application/pgp-signature x-mac-type=70674453; name=PGP.sig

		
---------------------------------
Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.

Re: HttpClient with Applet to upload files using MultipartPost is required....

Posted by Adrian Sutton <ad...@intencha.com>.
On 08/10/2004, at 5:21 PM, Srinivas Velidanda wrote:

> Hi,
>
> can I get the sample java code to make the signed applet with 
> HttpClient.

No unfortunately we develop a commercial product so I can't release the 
code.  However, the usage of HttpClient is exactly the same in an 
applet as an application.  You do however need to make sure the applet 
is signed and that you are using at least Java 1.3 (ie: you can't be 
using the Microsoft JVM that is the default in Windows IE).  When you 
load the applet it should bring up a security dialog asking if you want 
to give the applet permission to run, click yes and you have full 
permissions.

If you don't see that dialog then the applet isn't correctly signed.

> thanks,
> Srinivas.

Regards,

Adrian Sutton

----------------------------------------------
Intencha "tomorrow's technology today"
Ph: 3420 4584 0422236329
35 Prenzler St
Upper Mount Gravatt 4122
Australia QLD
www.intencha.com

Re: HttpClient with Applet to upload files using MultipartPost is required....

Posted by Srinivas Velidanda <sv...@yahoo.com>.
Hi,
 
can I get the sample java code to make the signed applet with HttpClient.
 
thanks,
Srinivas.

Adrian Sutton <ad...@intencha.com> wrote:

On 08/10/2004, at 4:43 PM, Srinivas Velidanda wrote:

> Hi,
>
> I got a sample signed applet working that is given at the links you 
> specified.
> but need help using it with HttpClient...
>
> Pl let me know if somebody already worked with applet using HttpClient.

Hi Srinivas,
We use HttpClient extensively from within a signed applet. As long as 
an applet is correctly signed, it has the same permissions as a 
stand-alone application.

> thanks.
> Srinivas.

Regards,

Adrian Sutton.

----------------------------------------------
Intencha "tomorrow's technology today"
Ph: 3420 4584 0422236329
35 Prenzler St
Upper Mount Gravatt 4122
Australia QLD
www.intencha.com


> ATTACHMENT part 2 application/pgp-signature x-mac-type=70674453; name=PGP.sig

		
---------------------------------
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.

Re: HttpClient with Applet to upload files using MultipartPost is required....

Posted by Adrian Sutton <ad...@intencha.com>.
On 08/10/2004, at 4:43 PM, Srinivas Velidanda wrote:

> Hi,
>
> I got a sample signed applet working that is given at the links you 
> specified.
> but need help using it with HttpClient...
>
> Pl let me know if somebody already worked with applet using HttpClient.

Hi Srinivas,
We use HttpClient extensively from within a signed applet.  As long as 
an applet is correctly signed, it has the same permissions as a 
stand-alone application.

> thanks.
> Srinivas.

Regards,

Adrian Sutton.

----------------------------------------------
Intencha "tomorrow's technology today"
Ph: 3420 4584 0422236329
35 Prenzler St
Upper Mount Gravatt 4122
Australia QLD
www.intencha.com