• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with setBufferSize()

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I am using VC++ client to get the data from servlet. This is the code i am using

public void doGet(...)
{
response.setBufferSize(20*1024)
BufferedOutputStream bos=new BufferedOutputStream(response.getOutputStream());
byte[] fileData=new byte[20*1024];

RandomAccessFile RAF = new RandomAccessFile ("xyz.avi", "r");
nBytestoWrite=RAF.read(fileData);
if(nBytestoWrite>-1)
{
bos.write(fileData,0,nBytestoWrite);
}
RAF.close();
}

When i am trying to get the data from VC++ client its showing like you have received 8KB only where as i am trying to get 20KB.


Thanks in advance
Prashanth
 
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Call your Servlet from a JSP and check whether you are getting proper data or not. If you are getting proper data in JSP, it means your VC++ client has come problem.

If you are not getting proper data in JSP file too, remove the buffer setting from Servlet and try again. If you are not getting proper data again, something is wrong with your Servlet. If you are getting proper data without buffer setting, it means buffer setting is giving problem.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No matter what buffering tricks you perform on the servlet side, actual transmission will be in TCP/IP blocks, so your C++ client must be prepared to read multiple times from the input stream until an eof is hit. You must also close the servlet output stream to ensure that the last chunk is sent.
Bill
 
Prashanth Chandra
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I am getting the same problem when I call a servlet from JSP.
Actually the problem is I am getting 20kb of data as whole.But I am getting it in the 8KB slots. i want it to be in a 20kb slot. Is there any method where i can get the data in slots based on my requirement?

regards
Prashanth
Thanks in advance
 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It also depends on VC++ client on how much it is ready to accept.

Ex:
Just because the server has 1 MBPS line, it doesn't mean that dial up user will get that speed when downloading.

It too depends on the client's connection settings and speed.
 
Prashanth Chandra
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I think if I set the Heap size of the server appropriately then this problem would be solved. Just need to know how to set the Heap size of the server. I have tried setting this environment varibles. Actually i use the O.S RHEL 3.0 and i have set the Heap size in bash_profile file in this way

CATALINA_OPTS="-server -Xmx256m"
JAVA_OPTS="-Xmx256m"
Does this work or else please let me know how toset this.


regards
Prashanth
Thanks in advance
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic