HTTP 请求 (POST) 字段大小限制& JSP 中的 Request.BinaryRead

发布于 2024-08-13 06:11:50 字数 307 浏览 4 评论 0 原文

首先,我的 Java 已经很生疏了,而且我从来没有做过 JSP 或 servlet,但我正在努力帮助别人解决问题。

由 JavaScript 呈现的表单正在回发到 JSP。 此表单中的某些字段大小超过 100KB。 然而,当在 JSP 端检索表单字段时,该字段的值将被截断为 100KB。

现在我知道 ASP Request.Form 中也存在类似的问题,可以通过使用 Request.BinaryRead 来解决。 Java 中有等效的吗?

或者,Websphere/Apache/IBM HTTP Server 中是否有一个设置可以解决同样的问题?

First off my Java is beyond rusty and I've never done JSPs or servlets, but I'm trying to help someone else solve a problem.

A form rendered by JavaScript is posting back to a JSP.
Some of the fields in this form are over 100KB in size.
However when the form field is being retrieved on the JSP side the value of the field is being truncated to 100KB.

Now I know that there is a similar problem in ASP Request.Form which can be gotten around by using Request.BinaryRead.
Is there an equivalent in Java?

Or alternatively is there a setting in Websphere/Apache/IBM HTTP Server that gets around the same problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

爱的十字路口 2024-08-20 06:11:50

由于 servlet 容器必须将发布的请求保留在内存中以提供 ServletRequest API 所需的功能,因此大多数 servlet 容器都具有可配置的大小限制以防止 DoS 攻击,否则少数虚假客户端可能会激怒服务器内存不足。

如果 WebSphere 默默地截断请求而不是正确失败,这有点奇怪,但如果这是问题的原因,您可能会找到配置选项 WebSphere 文档中

Since the posted request must be kept in-memory by the servlet container to provide the functionality required by the ServletRequest API, most servlet containers have a configurable size limit to prevent DoS attacks, since otherwise a small number of bogus clients could provoke the server to run out of memory.

It's a little bit strange if WebSphere is silently truncating the request instead of failing properly, but if this is the cause of your problem, you may find the configuration options here in the WebSphere documentation.

铃予 2024-08-20 06:11:50

我们已经解决了这个问题。
事实证明,与网络服务器设置无关,并且帖子中没有任何内容被截断。

发布之前的表单字段被 JavaScript 分割成 102399 字节大小的块,每个块都作为一个值添加到表单字段中,因此最终会得到一个值数组。
Request.Form() 似乎会自动连接这些值以重现单个巨型字符串,但 Java getParameter() 不会。
然而,使用 getParameterValues() 并根据返回值重建字符串就达到了目的。

We have resolved the issue.
Nothing to do with web server settings as it turned out and nothing was being truncated in the post.

The form field prior to posting was being split into 102399 bytes sized chunks by JavaScript and each chunk was added to the form field as a value so it was ending up with an array of values.
Request.Form() appears to automatically concatenate these values to reproduce the single giant string but Java getParameter() does not.
Using getParameterValues() and rebuilding the string from the returned values however did the trick.

红尘作伴 2024-08-20 06:11:50

您可以使用 getInputStream (原始字节)或 getReader(解码后的字符数据)从请求中读取数据。注意 这是如何实现的与读取参数进行交互。如果您不想使用 servlet,请查看使用 过滤换行 请求。

我希望 WebSphere 拒绝该请求而不是任意截断数据。我怀疑其他地方有错误。

You can use getInputStream (raw bytes) or getReader (decoded character data) to read data from the request. Note how this interacts with reading the parameters. If you don't want to use a servlet, have a look at using a Filter to wrap the request.

I would expect WebSphere to reject the request rather than arbitrarily truncate data. I suspect a bug elsewhere.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文