<html>
<body>
<!-- http://127.0.0.1:8080/ -->
<form action="http://java.csdn.net/" method="post" enctype="multipart/form-data">
<table border="1" align="center" width="230px">
<tr>
<td>
<input type="file" name="upLoad"/>
</td>
</tr>
<tr>
<td align="center">
<input type="submit" value="上传" style="width: 35%" id="upSubmit"/>
</td>
</tr>
</table>
</form> </body>
</html>
在上传给自己的tomcat时,没有做处理,就算访问的是不存在的webapp,tomcat也会一直下载,而我的浏览器也是一直在上传的,只见内存占用快速上升上面代码中测试了请求路径是:http://java.csdn.net/ 也是会一直上传的,可是改为:http://www.baidu.com/ 就不会有此问题了(显示:此程序无法显示网页)
挺奇怪的,怎么有的上传有的又不会了??不知道大家有没有解决办法,或者从web服务器怎样终止此次请求?web服务服务器tomcatwebappJavaEE
解决方案 »
- JSP 网上商城用户个人信息 显示历史购买记录 出现空指针异常
- 线程高手请进来,死锁导致high JVM问题
- hibernate 动态映射问题
- struts自带的BasicDataSource连接池只能在 action中使用吗,不能用在普通类里面吗?
- jsp中如何用${dept.academy.name}的使用--表间查询
- oracle数据库连接不上
- 急急急:tomcat安装服务后无法启动,但通过startup.bat却正常启动,访问也正常
- 错误在哪
- 30*24*60*60*1000等于多少
- ejb与oracle的问题:
- org.apache.jasper.JasperException: Unable to compile class for JSP:
- struts2.3.8的类型转换
ASK:I'm running a servlet in Tomcat 6.0.26. The servlet accepts file upload from the client by HTTP POST. I'd like to stop the file uploading from the HttpServlet side. I tried the following methods with no luck:1. close the request inputstream
2. send error code HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE and flush response
3. do 1 and 2 in a FilterI googled but found no direct answers. Please advise solutions.Thanks.
Answer:This is not possible using the standard Servlet nor Commons FileUpload API's. Basically, to be able to abort the connection immediately, you should grab the underlying socket physically and close it. However, this socket is controlled by the webserver. See also this related question:How to explicitly terminate http connection from server with no response header.Little tests have however confirmed that Commons FileUpload doesn't buffer up the entire file in memory when its size exceeds the limit. It will read the input stream, but just ignore and throw away the read bytes (also the ones which are already read). So memory efficiency isn't necessarily the problem here.To fix the real problem, you'd basically like to validate the file size in the client side rather than the server side. This is possible with a Java Applet or a Flash Application. For example, respectivelyJumpLoaderandSWFUpload.
测试过程发现,如果上传巨大的文件,服务端(commons-fileupload 实现)会抛出 FileUploadBase$SizeLimitExceededException ,并且服务端立即返回响应;但是浏览器显示仍在上传中(普通html file控件),如果放任其不管,会发现客户端内存不断攀升(并非浏览器进程),服务端内存也不断攀升,直至浏览器失去响应。(因此并非上述帖子中提到的:如果大小超限,服务端在抛出异常后,会将读取的数据丢弃,因为实际看来这些资源并没有被立即释放)。 再次询问有没有好的解决的办法?