开发者

Sending a HTTP post to a web server with Java

As per title really I'm wanting to send a custom HTTP post request to a web server and I have little experience in this area. The web server uses an LDAP server for access control (not sure if that's important) for which of course I know the username and password. Could anyone flesh out some code to do this or at开发者_JAVA百科 least get me started?

Edit for one of the comments, the server is running a LAMP stack with PhP 5+ and Apache 2+


You can use HttpClient module from Apache.

Although the java.net package provides basic functionality for accessing resources via HTTP, it doesn't provide the full flexibility or functionality needed by many applications. HttpClient seeks to fill this void by providing an efficient, up-to-date, and feature-rich package implementing the client side of the most recent HTTP standards and recommendations.

Designed for extension while providing robust support for the base HTTP protocol, HttpClient may be of interest to anyone building HTTP-aware client applications such as web browsers, web service clients, or systems that leverage or extend the HTTP protocol for distributed communication.


LDAP and authentication are separate issues from sending POSTs to web servers.

Th server side needs to do that authentication. Set it up either in your code or in the web server itself.

If your client is a Java application, you can create a POST using UrlConnection.

If your client is an HTML page or JSP, you need a form with a POST action.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜