• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet POST data size

 
Teboul Luc
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have a Servlet running in Tomcat 5.5.12.

The Servlet reads a parameter that is sent over HTTP using POST. The Parameter contains about 3000 characters of data of text. In the request.getParameterMap we can see 13 entries and the inital parameter has been split into strings of random sizes charachters chunks. eg some are about around 400 length, others are around 1000 length.

Why has this occured? Java can handle big String sizes, so why is it not just in one big string.

Thanks,
Luc.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65123
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How is the request being generated?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IF this was my problem I would try to use TCPMON to capture the exact request being sent. If you can't insert TCPMON into the request then I would use the request getInputStream() to capture the exact body in bytes (rather than getReader which will do a character conversion.) I bet you will find a surprise of some sort

Bill
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It might be the browser that is chunking the data.
This is an HTTP1.1 feature.
 
Teboul Luc
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for you previsous responses.

I generate the request in a C++ applcation. I create a http request and I had one POST parameter with my string.

Then I send this to a java web app and when I try to get my parameter in the servlet using request.getParameter, then I have realized that my string have been truncated.

Then I dynamically execute request.getParameterMap and then I get a map with 13 entries instead of just 1 and each entry contains a substring of my initial POST parameter.

I have tried to change the TOMCAT configuration especially the attributes
maxHttpHeaderSize and maxPostSize of the connector entry in the servel.xml file but it doesn't change anything.

Thanks.
Luc.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you encode your parameter before setting it in the request ?
 
Teboul Luc
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No I add it as a string direclty as a POST parameter.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to encode it first. It might have characters causing it to be split.
 
Teboul Luc
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In fact it seems that you might be right I think the charatere "&" seems to causes some problem.

But when you say try to encode it, what do I need to do?

Thanks.
Luc.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've got to encode it in Base64.
As you're using C++, I can't tell much about that I think you can find lots of samples on Internet. Or maybe a library you're using already has this functionality. Here's one :
http://base64.sourceforge.net/
[ March 07, 2007: Message edited by: Satou kurinosuke ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Satou kurinosuke:
You've got to encode it in Base64.


Post parameters aren't base64 encoded.
They are form-urlencoded.
http://www.w3.org/MarkUp/html-spec/html-spec_8.html#SEC8.2.1
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post parameters aren't base64 encoded

In your face Satou

Sorry for the wrong info here. As Ben pointed out, parameters are form-encoded
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic