This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to increase maximum size of data accepted?

 
Michal Glowacki
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

for some time I am looking for clear answer, how to increase maximum size of data, that comes to servlet in the request? I have a servlet that receives xml data from another server. I have been told by admin of that another server, to increase the maximum allowed size to 6MB, shoot me but I have no clue where to set it. When some bigger data comes, their server is sending it all the time, because no successful status comes from mine.

By maximum size of data I mean max size of request's parameter(s) (String xml = request.getParameter("data");)

Regards,
Michal
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13055
6
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The usual use of getParameter is for relatively short Strings from a HTML form submission.

If somebody was trying to POST megabytes of text to my servlet, I would avoid all the methods (such as get Parameter) which trigger the servlet container into trying to interpret the input as a form. Instead I would get the request body as a stream and try to process that.

See javax.servlet.ServletRequest.getInputStream()

With stream input you could process XML as either a Document or with a SAX or Stax parser.

What do you have to do with this XML?

Bill



 
Pete Nelson
Ranch Hand
Posts: 147
Debian Eclipse IDE Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It will depend on the server container you are using.

If you are using Tomcat directly, you can set the maxPostSize attribute for your http-connector (or ajp connector) to allow a 6 MB file. By default, Tomcat's HTTP (and AJP) connector limits this to 2 MB. See http://tomcat.apache.org/tomcat-6.0-doc/config/http.html

For other server containers, look for a similar setting in their documentation - they are very likely to have a similar setting.
 
Michal Glowacki
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the answers, I think Pete's answer should do the trick, as I had maxPostSize set to 2MB until now.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic