You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by barber barber <ba...@poesia.zzn.com> on 2005/01/26 09:20:50 UTC

Something is wrong with my hhttpclient

Hello,
 
 I,m a new user of httpclient. I,m trying to make login to my application web by httpclient:
 
  HttpClient httpClient = new HttpClient();
 
         try {
             PostMethod method  = new PostMethod("http://dirIp:9080/url/login.jsp");
 
             method.addParameter("user","xxx");
             method.addParameter("password","xxx");
            
 
 
             httpClient.executeMethod(method);
 
             String body = method.getResponseBodyAsString();
 
             System.out.println(body);
             method .releaseConnection();
 
         } catch (IOException e) {
             e.printStackTrace();  //To change body of catch statement use Options | File Templates.
         }
 
 
 It works, but when print then body, i get the code of the "login.jsp" and i want the code of the reedirected page, which must be the "error login page" or the "ini application page". I think it,s not making submit. 
 
 And another question if i have more than one form how i especify which one is submitted?
 
 I wait for your answer 
 Thanks very much for your time!! ;)
 


Obtenga su E-mail GRATUITO en http://poesia.zzn.com
____________________________________________________________
Para obtener su propio servicio de correo electrónico basado en la Multimalla, diríjase a http://www.zzn.com

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


Re: Something is wrong with my hhttpclient

Posted by Ortwin Glück <or...@nose.ch>.

barber barber wrote:
> I,m a new user of httpclient. I,m trying to make login to my
> application web by httpclient:

> 
> PostMethod method  = new
> PostMethod("http://dirIp:9080/url/login.jsp");
> 
> method.addParameter("user","xxx"); 
> method.addParameter("password","xxx");

> It works, but when print then body, i get the code of the "login.jsp"
> and i want the code of the reedirected page, which must be the "error
> login page" or the "ini application page". I think it,s not making
> submit.
> 

Barber,

I guess you are posting to the wrong page. Please look at the HTML code 
of login.jsp. It will have a <form> tag with a action="URI" attribute. 
You need to post to the action URI.

 > And another question if i have more than one form how i especify
 > which one is submitted?

Simple answer: you don't. As HttpClient is not aware of any HTML 
content, you must emulate a specific form by just providing all the form 
fields as parameters and posting it to the right URL.

 > I wait for your answer Thanks very much for your time!! ;)

HTH

Ortwin Glück


-- 
  _________________________________________________________________
  NOSE applied intelligence ag

  ortwin glück                      [www]      http://www.nose.ch
  software engineer
  hardturmstrasse 171               [pgp id]           0x81CF3416
  8005 zürich                       [office]      +41-1-277 57 35
  switzerland                       [fax]         +41-1-277 57 12

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