hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rosa <rml...@terra.es>
Subject HttpClient + Applet problem
Date Mon, 26 Sep 2005 09:56:27 GMT
I am developing an applet to send two byte arrays and two parameters to 
a server.

My applet code uses something like this
                  
..................................................................
                PostMethod pM = new PostMethod(url.getPath());
                try {
                   
                    byte [] oA = UtilXML.creaFXML(d1);
                    byte [] oP = UtilXML.creaFXML(d2);
                    pM.addParameter("fI", fIniStr);
                    pM.addParameter("fF", fFinStr);
                    ByteArrayPartSource hA = new 
ByteArrayPartSource("hA.xml", oA);
                    ByteArrayPartSource hP = new 
ByteArrayPartSource("hP.xml", oP);
                   
                   
                    FilePart p1 = new FilePart("hAu", hA);     //, 
"text/xml", "ISO-8859-1");
                    FilePart p2 = new FilePart("hPr", hP);    //, 
"text/xml", "ISO-8859-1");
                    Part[] partes = {p1, p2};
                   
                    pM.setRequestEntity(new 
MultipartRequestEntity(partes, pM.getParams()));
                    HttpClient cliente = new HttpClient();
                    
cliente.getHttpConnectionManager().getParams().setConnectionTimeout(30000);
                    int estado = cliente.executeMethod(pM);
                    if (estado == HttpStatus.SC_OK) {
                        System.out.println(
                            "Upload has finished, response=" + 
pM.getResponseBodyAsString()
                        );
                    } else {
                        System.out.println(
                            "Upload has failed, response=" + 
HttpStatus.getStatusText(estado)
                        );
                    }
                    pM.releaseConnection();
                }
                catch (Exception ex) {
                    ex.printStackTrace();
                    System.out.println("Exception "+ex.toString());
                    pM.releaseConnection();
                }
                      
...........................................................

It compiles fine, but when I try to load it into the web browser I get 
the following error

                java.lang.NoClassDefFoundError: 
org/apache/commons/httpclient/methods/multipart/PartSource

                at java.lang.Class.getDeclaredConstructors0(Native Method)

                at 
java.lang.Class.privateGetDeclaredConstructors(Unknown Source)

                at java.lang.Class.getConstructor0(Unknown Source)

                at java.lang.Class.newInstance0(Unknown Source)

                at java.lang.Class.newInstance(Unknown Source)

                at sun.applet.AppletPanel.createApplet(Unknown Source)

                at sun.plugin.AppletViewer.createApplet(Unknown Source)

                at sun.applet.AppletPanel.runLoader(Unknown Source)

                at sun.applet.AppletPanel.run(Unknown Source)

                at java.lang.Thread.run(Unknown Source)

 

Do some people know what is happening?

thanks in advance!

 Rosa


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


Mime
View raw message