Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Jetty/Howto/Configure Form Size"

< Jetty‎ | Howto
Line 5: Line 5:
  
 
Jetty limits the amount of data that can be posted back from a browser or other client to the server. This helps protect the server against denial of service attacks by malicious clients sending huge amounts of data.
 
Jetty limits the amount of data that can be posted back from a browser or other client to the server. This helps protect the server against denial of service attacks by malicious clients sending huge amounts of data.
 +
 +
The default maximum size permitted by Jetty is 200000 bytes.
 +
 +
You can change this default for a particular webapp, for all webapps on a particular Server instance, or all webapps within the same jvm:
  
  
 
== Changing for a single webapp ==
 
== Changing for a single webapp ==
  
Context files are normally located in <jetty.home>/contexts/ (see [[Jetty/Feature/ContextDeployer|ContextDeployer]] for more details). Context files can be used to configure the size of the maximum form content:
+
The method to invoke is:
  
<source lang="xml">
+
<source lang="java">
 +
ContextHandler.setMaxFormContentSize(int maxSize);
 +
</source>
  
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
+
You can do this either in a [[Jetty/Feature/ContextDeployer|context xml deployment descriptor]] externally to the webapp, or in a jetty-web.xml file in the webapp's WEB-INF directory.
  
  <Set name="contextPath">/</Set>
+
In either case the syntax of the xml file is the same:
  <Set name="war"><SystemProperty name="jetty.home" default="."/>/webapps/test.war</Set>
+
  
 +
<source lang="xml">
 +
 +
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
 
   <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
 
   <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
 
   <!-- Max Form Size                                                  -->
 
   <!-- Max Form Size                                                  -->
Line 27: Line 35:
 
== Changing for all apps on a Server ==
 
== Changing for all apps on a Server ==
  
<source lang="xml">
+
Set an attribute on the Server instance for which you want to modify the max form content size:
<!--?xml version="1.0"  encoding="ISO-8859-1"?-->
+
 
+
  
 +
<source lang="xml">
 
<configure class="org.eclipse.jetty.server.Server">
 
<configure class="org.eclipse.jetty.server.Server">
 
       <Call name="setAttribute">
 
       <Call name="setAttribute">
Line 36: Line 43:
 
       <Arg>200000</Arg>
 
       <Arg>200000</Arg>
 
     </Call>
 
     </Call>
 
 
  <set name="maxFormContentSize"></set>
 
 
</configure>
 
</configure>
 
</source>
 
</source>
 +
 +
== Changing for all apps in the jvm ==
 +
 +
Use the system property "org.eclipse.jetty.server.Request.maxFormContentSize".
  
 
| category = [[category:Jetty Howto]]
 
| category = [[category:Jetty Howto]]
 
}}
 
}}

Revision as of 01:18, 15 August 2011



Introduction

Modifying the maximum permissable size of submitted form content.

Form Content Size

Jetty limits the amount of data that can be posted back from a browser or other client to the server. This helps protect the server against denial of service attacks by malicious clients sending huge amounts of data.

The default maximum size permitted by Jetty is 200000 bytes.

You can change this default for a particular webapp, for all webapps on a particular Server instance, or all webapps within the same jvm:


Changing for a single webapp

The method to invoke is:

ContextHandler.setMaxFormContentSize(int maxSize);

You can do this either in a context xml deployment descriptor externally to the webapp, or in a jetty-web.xml file in the webapp's WEB-INF directory.

In either case the syntax of the xml file is the same:

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <!-- Max Form Size                                                   -->
  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <Set name="maxFormContentSize">200000</Set>
</Configure>

Changing for all apps on a Server

Set an attribute on the Server instance for which you want to modify the max form content size:

<configure class="org.eclipse.jetty.server.Server">
      <Call name="setAttribute">
      <Arg>org.eclipse.jetty.server.Request.maxFormContentSize</Arg>
      <Arg>200000</Arg>
    </Call>
</configure>

Changing for all apps in the jvm

Use the system property "org.eclipse.jetty.server.Request.maxFormContentSize".

Back to the top