Hi Gregg,
In the httpclient package, the only way to access an OutputStream that I
have found is in the class HttpConnection. But I am unable to figure out how
to create an HttpConnection with the path to my servlet. It only seems to
have constructors for setting host, port, protocol, etc, but not the path to
the actual servlet ("/myservlet"). Is there a way to create an
HttpConnection with a path beyond the host?
In HttpClient 2.0 there is no built-in way to direcly write to the output stream. You can accomplish what you are looking for by writing the object to a byte array and then using that for the post method. Something like:
ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(bos); out.writeObject(anObject);
PostMethod post = new PostMethod(); post.setRequestBody(new ByteArrayInputStream(bos.toByteArray()));
In HttpClient 3.0 things are much cleaner. You can write directly to the output stream by implementing a RequestEntity and setting it on the PostMethod.
Basically, I'm new to this package, and I would like to know if it will help
me accomplish what the code snippet above accomplishes (only without so many
failures). Also, will it help with my timeout problem? Any advice at all is
much appreciated.
Please have a look at the tutorial <http://jakarta.apache.org/commons/httpclient/3.0/tutorial.html> for more examples of how to use HttpClient.
You can set a variety of timeouts in HttpClient 3.0. The Preferences Architecture documentation <http://jakarta.apache.org/commons/httpclient/3.0/preference-api.html> discusses the various timeout settings.
Mike
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
