Skip to Content
0
Former Member
Sep 15, 2005 at 12:41 PM

http Header POST/GET + QueryStrings

45 Views

Hi,

I am facing the following problem:

I need to create an URL with a QueryString something like:

http://

/index.asp?var1=a&var2=b


and then this needs to be sent via

POSTmethod

to the webserver! Otherwise when using GET, I get redirected to a login-page. I checked this with an html-page, which carries a corresponding form - this works with POST Method. I need to get the url or the source of the response page in webdynpro!

Or is there a way to simulate the html-form?

I think there are jars available, which can sent files to an url - I thought about sending an html-header, as the form-POSTMethod puts the form variables in the html-Header, when sending. Is this possible?

Right now I am using the following classes:

import org.apache.commons.httpclient.HttpClient;

import org.apache.commons.httpclient.HttpException;

import org.apache.commons.httpclient.methods.*;

I am sending the URL via this:

		PostMethod post = new PostMethod(<b>url.toExternalForm()</b>);

		post.setRequestHeader("Content-type", "text/html; charset=ISO-8859–1");

		HttpClient httpclient = new HttpClient();
		
		int iResultCode = httpclient.executeMethod(post);

		msgMgr.reportSuccess("iResultCode = " + iResultCode);

		byte[] yaResponse = post.getResponseBody();

		msgMgr.reportSuccess("Server response:"+new String(yaResponse));
		
		post.releaseConnection();

does somebody know, if "url.toExternalForm()" creates something like a form, which then again can be sent via POST? right now i get redirected to a login-page. So it seems my postMethod is infact a GET...

any ideas welcome,

thanx matthias