servlet taking much costly time


Web tier: servlets, JSP, Web frameworks: servlet taking much costly time

  1. servlet taking much costly time (4 messages)


    Is it problem with the servlets that it take much time to respond. My client is trying to connect to servlet which is sending continuous stream of images through HTTP connection. Do I have to change my servlet engine (I am using tomacat).

    Any help will be appreciated.

    Threaded Messages (4)

  2. mmm[ Go to top ]

    I think taking much costly time mayby cause by sorts of reason!can you tell me your servlet do something?
  3. response[ Go to top ]


    I have Doja application,i-appli (similar to Midlet) which is taking continous stream of images from the servlet running on tomcat engine.

    For the servlet sending normal text I got the response in just a 1-2 sec. but for this servlet which is taking the image from Fileinputstream (the real path one)and sending into outputstream, it is taking about 21 sec for HTTP connection OK response

    I think i have to optimize code on the servlet side as my client application only supports HTTP protocol.

    My servlet code looks like

    //sending 5 image files to outputstream

    filename = sc.getRealPath("pic"+i+".jpeg" ;//get path of pic.
    file = new File(filename);
    mimeType = sc.getMimeType(filename);
    resp.set ontentType(mimeType);
    in = new FileInputStream(file);
    count =;
    out.writ (buf,0,count);
    in.close );
    out.clos ();

    Can there be any method of putting the byte chunk of images into outputstream faster than this.

    Any help wiil be appreciated.

    Thanks in advance.

  4. zip stream[ Go to top ]

    Why dont u zip the contents and dump them into the output stream - and on the client side, unzip them
  5. raw image[ Go to top ]


    I want to take the raw image data directly from the inputstream on the client side i.e. reading the stream and then displaying it on the handset through Mediamanager.
    I have tried through compression decompression but no such improvement

    I think i need to change my code ?

    Any help in this regard will be implemented

    Kapil Sharma