| Author |
Problem with setBufferSize()
|
Prashanth Chandra
Ranch Hand
Joined: Dec 07, 2005
Posts: 78
|
|
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
|
 |
Chetan Parekh
Ranch Hand
Joined: Sep 16, 2004
Posts: 3636
|
|
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.
|
My blood is tested +ve for Java.
|
 |
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12269
|
|
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
|
Java Resources at www.wbrogden.com
|
 |
Prashanth Chandra
Ranch Hand
Joined: Dec 07, 2005
Posts: 78
|
|
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
|
 |
Manesh Kumar
Ranch Hand
Joined: Mar 21, 2006
Posts: 94
|
|
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.
|
Manesh
|
 |
Prashanth Chandra
Ranch Hand
Joined: Dec 07, 2005
Posts: 78
|
|
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
|
 |
 |
|
|
subject: Problem with setBufferSize()
|
|
|