Bonjour,
je voudrais uploader un fichier sur un serveur http en simulant la méthode post qu'utilise les formulaires html (mon appli java est donc coté client): pouvez-vous m'aider svp ?
Bonjour,
je voudrais uploader un fichier sur un serveur http en simulant la méthode post qu'utilise les formulaires html (mon appli java est donc coté client): pouvez-vous m'aider svp ?
Je n'ai pas de réponse : ça veut dire que c'est impossible ? ou que je suis dans la mauvaise section du fofo ?
Sinon, jette un oeil à la méthode URLConnection.
Il me semble qu'il faut récupérer une URLConnection via l'appel de la méthode openConnection() de la classe URL.
Ensuite, il faut utiliser la classe HttpURLConnection et notamment setRequestMethod("POST") pour simuler une requête POST.
Après il faut probablement utiliser l'OutputStream de l'URLConnection je pense...
ok merci beaucoup, je vais regarder ça de plus près
vous connaissez un bon tuto sur le HTTPClient de Jakarta ?
j'ai telechargé la library httpclient de jakarta => j'ai recupéré le fichier : commons-httpclient-3.1.jar
J'ai essayé de tester ce code d'exemple : http://svn.apache.org/viewvc/httpcom...18&view=markup
=> mais impossible de le faire focntionner : la bibliotheque org.apache.commons.httpclient est introuvable => comment fait-on pour l'installer ?
remarque : je travaille sous eclipse
j'ai enfin réussi à installer la lib,il fallait la définir dans le build path du projet : clic droit sur le projet => Build Path => Configure Build Path ... => onglet lbraries => Add External JARs...
ça compile bien et lorsque j'execute le programme, la fenetre s'affiche correctement
Mais j'ai toujours un problème => lorsque je clic sur le bouton d'envoie, j'ai les messages suivants qui apparaissent :
et j'ai aussi comme message d'erreur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory at org.apache.commons.httpclient.HttpMethodBase.<clinit>(HttpMethodBase.java:104) at MultipartFileUploadApp$MultipartFileUploadFrame$2.actionPerformed(MultipartFileUploadApp.java:179) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) ... 27 more
=> je ne sais pas quoi faire : pouvez-vous m'aider ?The source attachment does not contain the source for the file HttpMethodBase.class.
You can change the source attachment by clicking Attached source below
merci d'avance.
Vous avez un bloqueur de publicités installé.
Le Club Developpez.com n'affiche que des publicités IT, discrètes et non intrusives.
Afin que nous puissions continuer à vous fournir gratuitement du contenu de qualité, merci de nous soutenir en désactivant votre bloqueur de publicités sur Developpez.com.
Partager