• 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 Payload Size - XMLHttpRequest ("Content-type", "text/xml")

 
Ranch Hand
Posts: 226
1
jQuery Postgres Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:

 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 koomen
Ranch Hand
Posts: 226
1
jQuery Postgres Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I will move this to IO/Streams. I think that is the right place.

Eric
 
marten koomen
Ranch Hand
Posts: 226
1
jQuery Postgres Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 koomen
Ranch Hand
Posts: 226
1
jQuery Postgres Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Too many men are afraid of being fools - Henry Ford. Foolish tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic