on 09-15-2005 1:41 PM
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
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-88591");
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
Hello Matthias,
This 2 documents seems for me pretty detailed to solve your problem:
http://jakarta.apache.org/commons/httpclient/methods/post.html
http://java.sun.com/j2se/1.4.2/docs/api/java/net/URL.html#toExternalForm()
Best regards, Maksim Rashchynski.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.