Java开发者论坛离线版(http://www.ChinaJavaWorld.com)
主题用websphere上传文件不成功的问题

发贴�stxixi 发贴时间:Wed Jun 19 10:00:17 CST 2002
内容
我用webshpere4.0,打了fix_pack_2中对websphere的补丁,但是上传文件还是不正常。在上传过程中,经常出现异常。遇到出现异常上传不成功的情况,同一个文件多次尝试才能成功。而且我部署在一台服务器上最大可以上�400多k的文件,但部署在另外一台服务器上却最多却只能上传30k的文件�
我尝试跟踪异常,发现req.getContentLength()返回的数值笔上传文件的大小还小!接着在循环读入输入内容时in.read(b,i,size)就抛出了一个数组越界的异常�
难道websphere或者ibm apache有什么参数可以调整?
百思不得其解,请高手赐教!拜托拜托�
浏览网上本帖子最新内�
Copyright Java开发�------www.ChinaJavaWorld.com

回复�auto163   回复时间:Wed Jun 19 10:42:43 CST 2002
回复内容
我们也遇到这样的问题.

真是搞笑,这的声势浩大的AppServer竟然连传个文件都不行.

全部是服务器运行中的乱七八糟的东东。(就是传完文件,竟然发现都是以前一些请求的内容�




回复�auto163   回复时间:Wed Jun 19 17:21:25 CST 2002
回复内容
我已经把贴子装载�

http://www.knowledgelab.net/cgi-bin/bbs/viewthread.php?tid=1381




回复�stxixi   回复时间:Thu Jun 20 13:29:39 CST 2002
回复内容
你打了补丁吗?我在打补丁之前得到的东西也是那些乱七八糟的东西,打了补丁之后的错误又是另外一回事了。你的代码我看过了,除了使用的具体函数不一样外,基本原理都相同啊�


回复�auto163   回复时间:Thu Jun 20 14:28:16 CST 2002
回复内容
黑,那个ibm的人不承认了?!

你不加把劲,看他还有什么办法?


回复�stxixi   回复时间:Fri Jun 21 13:42:54 CST 2002
回复内容
ibm的值班工程师在吗?帮帮忙吧!实在是着急啊�


回复�jingmc   回复时间:Mon Jun 24 10:29:37 CST 2002
回复内容
我不� IBM 的值班工程师�
为了区分是否是由于WAS v4.01�2001/08版)的一个古老的Http Server Plug-in buffer overflow的问题,您可以直接通过WAS的Web Container 来上传文件,WAS的Web Container支持HTTP协议,缺省端口为 9080�
如果直接使用 WAS � Web Container 可以上传文件,则问题是由� HTTP Server plug-in buffer overflow 的bug,请升级 WAS � v4.02 以上。在升级时,切记要先停止 HTTP Server � WAS,否则升级一定会失败�


回复�stxixi   回复时间:Mon Jun 24 13:27:33 CST 2002
回复内容
to jingmc , 我已经升级到4.0.3了,打fp3时没有报错。我说的用web container的方法我会试一试。还有我把代码贴在下面了,请大家看看有什么错�

try{//获得提交数据�
data = req.getInputStream();
size = req.getContentLength();
in = new BufferedInputStream(data,size);
}catch(Exception e1){}
b=new byte[size];
for(i =0;i<size;i++){
b[i] = 0;
}
i = 0;
try{
int j = 0;
while (true){
j = in.read(b,i,size);
i = i + j;
if (i >= size){break;}
}
in.close();
}catch(Exception e3){//经常抛出数组越界的异�
}

发生异常时req.getContentLength()返回的数值笔上传文件的大小还小!接着在循环读入输入内容时in.read(b,i,size)就抛出了一个数组越界的异常�


回复�sunyiq   回复时间:Mon Jun 24 18:23:23 CST 2002
回复内容
看下面这篇文章。含测试的例子�

1.Introduction
This is a sample that uploads text or image files from the browser to the web server.
When IBM's ISVs use WebSphere Application Server,they have the requirement to
upload text or image files from the browser to the server.

On IBM platform, the recommended approach is to write a servlet.  
It is understood that a form using "multipart/form-data" can transmit the file
content in the form back to the server.   The servlet can then parse the parameters
from the form and save the embedded file on the server.  

This document describes how to use the servlet.

2.Source file
(1).IRNewItemServlet.java
(2).IRMultiDataFormParser.java
(3).IRException.java

3.Test Environment
(1).Windows NT Server 4.0
(2).Netscape Communication Browser 4.0 and Microsoft IE 4.0
(3).IBM WebSphere


4.Usage
(1) Complile three java source files to generate three class files
(2) Put these three class files into WebSphere's servlets directory
(3) Put the sample html file UploadServletForm.html into the document directory of WebServer
(4) Invoke these servlets via URL UploadServletForm.html

5.Browser End Behavior

The server should serve up a form that enables the browser user to select
one file from the local file system (local to the browser).    

The form must contain the following fields:
- source file: the fullpath name of the source file;
- target filename: the name this file will be stored as on the server side.  
This field  should be initialized to the name of the selected file, but the user
can over-write this to a different name.
- replace or not: this is a boolean field which the user is to fill in yes or no.  

The form must contain the following buttons:
- a "browse" button which allows the user to select a file,
- an "upload" button to indicate that the selection is complete and file upload
can begin.

When the "browse" button is pressed, the local file system should be
displayed, probably as in windows explorer.    When the user selects a file,
the full pathname of the selected file is filled into the source file field
in the form.

The user can type over the target filename and target directory pathname
before pressing the "upload" button.   When the "upload" button  is pressed,
the form (with the appropriate parameters and file content) is sent back to the server.    

Presumably the selected file (pathname as well as file content) is
sent back to the server with the form.    If the server fails to store the file
successfully, appropriate error messages should be displayed in the browser.  
Possible error messages are:
- "file data corrupted",
- "file system is full",
- "error saving file",
- "target file already exists and user elects not to replace it", etc.

If the file is saved successfully, a message should be displayed at
the browser to indicate success.


6.Server Behavior

When the form response is received, the server should
- parse the returned form for the parameters related to the file, and
- store the file data in the server's file system using the directory and
file names returned with the form.   If the directory or the file name doesn't
exist yet, it is created.   If the file already exists, the file is replaced
if the user so indicated.   Otherwise an error is returned.

The server assumes a default directory under which the file is stored (in the sample,
the directory is c:\temp.)The file name is the same as the source file (passed back
to the server as a parameter).

The server then sends a message to the client indicating the status
(success or failure, and error code if failure) of the file upload.    The
application can terminate after sending the message, or wait until invoked again.    

7.Design Considerations

This sample program is defined to demonstrate how to implement the file
upload functionality using IBM's WebSphere, and to provide re-useable code for
ISVs who need this function.   For the latter reason, the design should provide
the appropriate interface so an ISV application can easily integrate with it.

The file to be up-loaded can  be either text or image.

One can upload a file using <INPUT TYPE="file"> within a FORM tag. This will
allow you to select files through browse button.To upload more than one file
it needs to define multiple <INPUT TYPE="file"> tags as it is not possible to
choose multiple files through a single INPUT tag.



回复�stxixi   回复时间:Tue Jun 25 09:20:08 CST 2002
回复内容
谢谢各位。我发现打补丁是一部分,我的程序里的错误也是一个原因。改了in.read(b,i,size-i)后可以上传至�2m的文件了�


回复�kmonkey   回复时间:Tue Jun 25 11:42:57 CST 2002
回复内容
http://61.144.28.245/hjc/mycgi/bbs/topic.cgi?forum=34&topic=97

这是jingmc的答复,按照他的答复,我的问题解决了,跟楼主所说的问题一样�


回复�auto163   回复时间:Wed Jun 26 22:25:28 CST 2002
回复内容
果然是与 Http Server 有关�

用上9080就好多了�


回复�liugangwcm   回复时间:Mon Jul 29 17:23:31 CST 2002
回复内容
各位老大:我碰到了同样的问题,快急死了,先自己做的上传类,后来有网上公布的jspmartupload都遇到了同样的问题:在windows 的visalage for java的测试环境下,或weblogic下怎么玩都行,但在unix下websphere上传太大的文件就不行,而且还限制文件的类型,jsp、zip、doc都传不上去!
各位有什么高见,救救小弟吧!


回复�liugangwcm   回复时间:Mon Jul 29 17:26:09 CST 2002
回复内容
各位老大:我碰到了同样的问题,快急死了,先自己做的上传类,后来有网上公布的jspmartupload都遇到了同样的问题:在windows 的visalage for java的测试环境下,或weblogic下怎么玩都行,但在unix下websphere上传太大的文件就不行,而且还限制文件的类型,jsp、zip、doc都传不上去!
各位有什么高见,救救小弟吧!

而且我存超长字符串时用到流存储时也出现这个情况,怀疑websphere环境下对流的操作有问题!



Copyright Java开发�:www.chinajavaworld.com(webmaster: [email protected])