Hello,

first, you should try to add the following:

method.addParameter("abcv", "View")

because a submit button also defines a parameter
when it is given a name.

Due to the onclick handler, there should be a POST
request as well as the modification of the location.
I can't tell whether the location change affects the
current page or the one returned by the POST. It
seems more reasonable if it affects the current
page. Either way, since the new URL starts with a
#, it probably only scrolls the page that is shown to
an anchor within the page. Maybe to move the
submit button out of view, for those impatient users
that would click on it again and again.

cheers,
  Roland





Spam Proof <[EMAIL PROTECTED]> 
13.09.2004 14:13
Please respond to
"Commons HttpClient Project"


To
[EMAIL PROTECTED]
cc

Subject
Unable to use post with a site






Hi,
 
I am using httpclient to post some data to a website.
 
The actual url that I am trying to post to is 
http://www.amfiindia.com/navreport.asp
 
The asp page corresponding to the form is given below 
 
-------navreport.asp------begin--------
<form name="abc" method="post" action="navreport.asp">
     <select size="1" name="cmbmf">
            <option value="all">ALL</option>
            <option value=39>abc</option> 
...
 </select>
<input type="submit" value="View" name="abcv" 
onclick="location.replace('#123')">
-------navreport.asp------end----------
 
I use the following code:
 
String url = "http://www.amfiindia.com/navreport.asp";;

HttpClient client = new HttpClient();

PostMethod method = new PostMethod( url );

method.addParameter( "cmbmf", "all" );



method.setFollowRedirects(true);

int statusCode = client.executeMethod( method );

if( statusCode != -1 ) {

String contents = method.getResponseBodyAsString();

method.releaseConnection();

System.out.println( contents );

}

Instead of the posted results, I am getting the page containing the form. 
Should I use a different url because of the 
onclick="location.replace('#123')" in the submit button?


Yahoo! India Matrimony: Find your life partneronline.

Reply via email to