开发者

Analog of PHP "MAX_FILE_SIZE" param for JSP

Is there analog of PHP "MAX_FILE_SIZE"开发者_开发百科 parameter for JSP?

It's needed to perform validation on UI before upload process triggered on backend.


The setSizeMax() method in Apache Commons FileUpload's ServletFileUpload class lets you set the maximum size to accept in the request. If the request body is larger than the max, it will throw a SizeLimitExceededException. Details at http://commons.apache.org/fileupload/.


That depends on the servletcontainer in question, not on JSP. As you didn't mention which one you're using, I'll only take Apache Tomcat as an example.

It's technically actually the maximum size of the request body. The request body is the one which is been filled POST requests. It is often only exceedingly large when it's used to upload file(s). In Tomcat the maximum size is configureable as maxPostSize attribute of the <Connector> element in /conf/server.xml which defaults to 2MB. Here's an example with 2MB:

<Connector maxPostSize="2097152">

You can find more details in this this Tomcat-specific document. If you're using a different make, you'll need to consult its documentation, but you now at least know where to look and on which keywords.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜