IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Services Web Java Discussion :

[debutant]Simuler un formulaire html => methode post


Sujet :

Services Web Java

  1. #1
    En attente de confirmation mail
    Profil pro
    Inscrit en
    Octobre 2003
    Messages
    1 249
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2003
    Messages : 1 249
    Points : 314
    Points
    314
    Par défaut [debutant]Simuler un formulaire html => methode post
    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 ?

  2. #2
    En attente de confirmation mail
    Profil pro
    Inscrit en
    Octobre 2003
    Messages
    1 249
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2003
    Messages : 1 249
    Points : 314
    Points
    314
    Par défaut
    Je n'ai pas de réponse : ça veut dire que c'est impossible ? ou que je suis dans la mauvaise section du fofo ?

  3. #3
    Modérateur
    Avatar de dinobogan
    Homme Profil pro
    ingénieur
    Inscrit en
    Juin 2007
    Messages
    4 073
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France

    Informations professionnelles :
    Activité : ingénieur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 4 073
    Points : 7 163
    Points
    7 163
    Par défaut
    Citation Envoyé par Emcy Voir le message
    Je n'ai pas de réponse : ça veut dire que c'est impossible ? ou que je suis dans la mauvaise section du fofo ?
    Non, rien de tout ça.
    Tu as plusieurs possibilités, la plus simple pour toi serait probablement d'utiliser le HTTPClient de Jakarta.

  4. #4
    Invité
    Invité(e)
    Par défaut
    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...

  5. #5
    En attente de confirmation mail
    Profil pro
    Inscrit en
    Octobre 2003
    Messages
    1 249
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2003
    Messages : 1 249
    Points : 314
    Points
    314
    Par défaut
    ok merci beaucoup, je vais regarder ça de plus près

  6. #6
    En attente de confirmation mail
    Profil pro
    Inscrit en
    Octobre 2003
    Messages
    1 249
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2003
    Messages : 1 249
    Points : 314
    Points
    314
    Par défaut
    vous connaissez un bon tuto sur le HTTPClient de Jakarta ?

  7. #7
    En attente de confirmation mail
    Profil pro
    Inscrit en
    Octobre 2003
    Messages
    1 249
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2003
    Messages : 1 249
    Points : 314
    Points
    314
    Par défaut
    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

  8. #8
    En attente de confirmation mail
    Profil pro
    Inscrit en
    Octobre 2003
    Messages
    1 249
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2003
    Messages : 1 249
    Points : 314
    Points
    314
    Par défaut
    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 :
    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
    et j'ai aussi comme message d'erreur :
    The source attachment does not contain the source for the file HttpMethodBase.class.
    You can change the source attachment by clicking Attached source below
    => je ne sais pas quoi faire : pouvez-vous m'aider ?

    merci d'avance.

Discussions similaires

  1. Réponses: 10
    Dernier message: 19/09/2014, 20h53
  2. Réponses: 2
    Dernier message: 15/07/2009, 16h26
  3. action de formulaire, URL et methode POST
    Par Mathieu72 dans le forum Langage
    Réponses: 4
    Dernier message: 16/06/2007, 21h35
  4. Simuler un formulaire Post
    Par Boeing dans le forum Langage
    Réponses: 1
    Dernier message: 03/07/2006, 22h42
  5. [VB.NET] methode post de formulaire
    Par HULK dans le forum ASP.NET
    Réponses: 6
    Dernier message: 10/06/2005, 16h48

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo