You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Saint-Martin Cécile <Ce...@ouest-france.fr> on 2003/09/24 15:30:52 UTC

RE : Broken pipe in Servlet.sercice()

Code for ApplicationObjectServlet :

  private void recupererListe(  HttpServletRequest request,
                                HttpServletResponse response,
                                String nomObjet)
    throws IOException {

    try {
      List listeDonnee = (List)
UtilsCom.litSurFluxZippe(request.getInputStream());

      ServletContext context = getServletContext();

      listeDonnee = (List) context.getAttribute("Liste" + nomObjet);

      ByteCounterOutputStream byteCounterStream =
                      new
ByteCounterOutputStream(response.getOutputStream());
      int start = byteCounterStream.bytesWrittenSoFar();

      UtilsCom.ecritSurFluxZippe((Serializable)listeDonnee,
byteCounterStream);

      int objectSize = byteCounterStream.bytesWrittenSoFar() - start;

      log.debug("Taille de l'objet serialise : " + objectSize + " octets");

      _nbBytesWritten += objectSize;
    }
    catch (ClassNotFoundException ex) {
      if (log.isEnabledFor(Priority.ERROR)) {
        log.error(ex.toString());
      }
    }
  }

ByteCounterOutputStream  is just a class that inherit from DataOutputStream
and that permits to know the number of bytes written.

Here is the code for UtilsCom :

  public static void ecritSurFluxZippe(Serializable objectToSerialize,
OutputStream out)
  throws java.io.IOException{
    GZIPOutputStream zipStream = new GZIPOutputStream(out);
    ObjectOutputStream objectOutput = new ObjectOutputStream(zipStream);
    objectOutput.writeObject(objectToSerialize);
    objectOutput.flush();
    objectOutput.close();
  }

Cécile SAINT-MARTIN
Ouest-France
Tel. 77.24
mailto:cecile.saint-martin@ouest-france.fr


> Howdy,
> 
> >We use a servlet to send serialized data to a java client. It always
> append
> 
> Post the relevant servlet code.
> 
> >Is there a limitation to the size of data that we can send 
> by a socket?
> 
> No.
> 
> Yoav Shapira
> 
----------------------------------------------------------------------------
-------------- 
Les informations ou pièces jointes contenues dans ce message sont
confidentielles. Seul le destinataire expressément visé peut en prendre
connaissance. Toute autre personne qui en divulguera, diffusera ou prendra
des copies sera passible de poursuites. La société Ouest-France décline en
outre, toute responsabilité de quelque nature que ce soit au titre de ce
message s'il a été altéré, déformé ou falsifié.
----------------------------------------------------------------------------
--------------

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org