This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Servlets and the fly likes Servlet POST data size Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet POST data size" Watch "Servlet POST data size" New topic
Author

Servlet POST data size

Teboul Luc
Greenhorn

Joined: Mar 06, 2007
Posts: 4
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

Joined: Jan 10, 2002
Posts: 61106
    
  66

How is the request being generated?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
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

Joined: Dec 11, 2004
Posts: 13410

It might be the browser that is chunking the data.
This is an HTTP1.1 feature.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Teboul Luc
Greenhorn

Joined: Mar 06, 2007
Posts: 4
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

Joined: Nov 24, 2005
Posts: 14687
    
  16

Do you encode your parameter before setting it in the request ?


[My Blog]
All roads lead to JavaRanch
Teboul Luc
Greenhorn

Joined: Mar 06, 2007
Posts: 4
No I add it as a string direclty as a POST parameter.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Try to encode it first. It might have characters causing it to be split.
Teboul Luc
Greenhorn

Joined: Mar 06, 2007
Posts: 4
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

Joined: Nov 24, 2005
Posts: 14687
    
  16

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

Joined: Dec 11, 2004
Posts: 13410

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

Joined: Nov 24, 2005
Posts: 14687
    
  16

Post parameters aren't base64 encoded

In your face Satou

Sorry for the wrong info here. As Ben pointed out, parameters are form-encoded
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet POST data size