commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adamowski, Marcin" <>
Subject RE: [HttpClient] HttpClient with JRun Webserver
Date Wed, 11 Aug 2004 15:05:23 GMT
Ok it works.

I was returning EntityEnclosingMethod.CONTENT_LENGTH_CHUNKED; from getContentLenght() method
as suggested on the mailing list, and it worked with Tomcat but not with JRun, so I calculated
proper lenght of the stream + 1 (don't ask me why, but only then it worked).

Anyway the code is below..

This one enables to send any Object to the web server from the client

public class ObjectRequestEntity extends ByteArrayRequestEntity
   public static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(ObjectRequestEntity.class);

   Object object = null;

   public ObjectRequestEntity(Object content){
     object = content;

   public ObjectRequestEntity(Object content, String contentType){
     object = content;

  public void writeRequest(OutputStream out) throws IOException{
    ObjectOutputStream oos = new ObjectOutputStream(out);

  public long getContentLength() {
//    return EntityEnclosingMethod.CONTENT_LENGTH_CHUNKED;
    long size = EntityEnclosingMethod.CONTENT_LENGTH_CHUNKED;
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      ObjectOutputStream oos = new ObjectOutputStream(baos);
      byte[] bytes = baos.toByteArray();
      size = bytes.length+1;
      log.debug("ContentLength : "+size);
    }catch(IOException ex){
    return size;


-----Original Message-----
From: Adamowski, Marcin []
Sent: 11 August 2004 13:24
To: ''
Subject: [HttpClient] HttpClient with JRun Webserver

Does anyone used HttpClient with JRun Webserver?

I'm trying to do something like that

Code from the client

String url = "http://localhost:8100/test.jsp";
HttpClient client = new HttpClient();
PostMethod post = new PostMethod(url);
post.setRequestEntity(new StringRequestEntity("sample String"));

Code from the jsp page

ServletInputStream s = request.getInputStream(); ois = new;

When I'm using Tomcat, everything is fine, but on JRun when I'm trying to create ObjectInputStream
I've got an exception.


Does onyone know what's wrong?

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message