post - Java sending request multipart/form data -


i'm trying send http request web using post, want mimic behavior of form , resulting html code.

<form action="http://www.myweb.com/index.php?route=account/login"     method="post" enctype="multipart/form-data">     <div class="content">       <p>ya soy cliente</p>       <b>dirección e-mail:</b><br>       <input type="text" name="email" value="">       <br>       <br>       <b>contraseña:</b><br>       <input type="password" name="password" value="">       <br>       <a href="http://www.myweb.com/index.php?route=account/forgotten">contraseña olvidada</a><br>       <br>       <input type="submit" value="entrar" class="button">               </div>   </form> 

so far, i've used httpclient apache, doesn't work. next message:

executing request post http://www.myweb.com/index.php?route=account/login http/1.1  http/1.1 200 ok response content length: -1  http/1.1 200 ok response content length: -1  org.apache.http.conn.eofsensorinputstream@47cdbe2 

the code:

 httpclient httpclient = new defaulthttpclient();     try {         httppost httppost = new httppost("http://myweb.com/" +                 "index.php?route=account/login");          stringbody email = new stringbody("myemail@email.com");         stringbody pass = new stringbody("mypass");          multipartentity reqentity = new multipartentity();         reqentity.addpart("email", email);         reqentity.addpart("password", pass);          httppost.setentity(reqentity);          system.out.println("executing request " + httppost.getrequestline());         httpresponse response = httpclient.execute(httppost);         httpentity resentity = response.getentity();          system.out.println("----------------------------------------");         system.out.println(response.getstatusline());         if (resentity != null) {             system.out.println("response content length: " + resentity.getcontentlength());             system.out.println(resentity.getcontent());         }         entityutils.consume(resentity);     } {         try { httpclient.getconnectionmanager().shutdown(); } catch (exception ignore) {}     } 

any idea how working? thanks


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -