Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with Payload Size - XMLHttpRequest ("Content-type", "text/xml")

 
marten kay
Ranch Hand
Posts: 188
Java jQuery Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I'm creating a xhtml snippet on a webpage and then sending that snippet back to a servlet. This works fine until the xhtml snippet becomes too long, when I get erratic results with the string apparently randomly truncated.

Is there a size limit on the XMLHttpRequest payload?

Should I use another method?

Thanks


My Client Code is so


My Server Code is so:

 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should have nothing to do with the XMLHttpRequest object since it is a plain old http call.

You can test it out, type the address to what you are caling into the browser and see if it is truncated. If it is, than you know it is your server that has the problem.

Eric
 
marten kay
Ranch Hand
Posts: 188
Java jQuery Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, I have tested it out,
1) I know that the what is put in the payload is completed
2) What is in the payload is truncated when I iterate over the Buffered Reader

As it is unlikely to be in the XMLHttpRequest, there is something wrong on the server side - either the server handling of the request or the Buffered Reader.

I may ask in another forum.

Cheers
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will move this to IO/Streams. I think that is the right place.

Eric
 
marten kay
Ranch Hand
Posts: 188
Java jQuery Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Eric

I have changed the input to use a StringBuilder instead of using the "+" to concatenate, but I still have the same problem.

revised server side code below


 
marten kay
Ranch Hand
Posts: 188
Java jQuery Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, I fixed the problem.

for now

I changed the BufferedReader as per below



I googled a bit, found some posts suggesting the Tomcat truncates requests over 8K when accessed using request.getReader(), so I am accessing the load using request.getInputStream() instead, and making a buffer out of that as show above.

Thanks again
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!