日期:2014-05-20  浏览次数:21050 次

WebSphere Application Server does not support double reading of the input stream , 幫幫忙看看是什麼問題..........
翻譯了一點點...好多都不太會.幫幫忙.


WebSphere Application Server does not support double reading of the input stream
譯:(websphere 應用服務器不支持對同一個輸入流進行兩次讀取)
 

 
Problem(Abstract)  
譯:(問題 摘要)
Calls to the getParameter family of methods fail after the input stream has been read from a request. 
 譯: 這個輸入流,在被一個請求調用getParameter()成員方法失敗后,又被另一個請求讀取過.  


Cause
When a request's HTTP method is POST, the request parameters are sent with 
the post form data. If the input stream is read, then the request parameters 
are no longer available by way of the getParameter family of methods. The Web 
Container will log the following exception:


  SRTServletReq E SRVE0133E: An error occurred while parsing parameters. java.io.IOException:SRVE0216E: post body contains less bytes than specified by content-length
at com.ibm.ws.webcontainer.servlet.RequestUtils.parsePostData(RequestUtils.java:538)
at com.ibm.ws.webcontainer.srt.SRTServletRequest.parseParameters(SRTServletRequest.java:1159)
at com.ibm.ws.webcontainer.srt.SRTServletRequest.getParameterMap(SRTServletRequest.java:1666)
at javax.servlet.ServletRequestWrapper.getParameterMap(ServletRequestWrapper.java:211)

 

Resolving the problem
It is working as designed. As stated in the Servlet Specification, the restriction on WebSphere® Application Server is that it cannot call the read method on the return object from HttpServletRequest#getInputStream(). The following scenarios show how to cause this problem.
The problem occurs because: 

1. When the request arrives in the server, the Web Container request wrapper object notes the existence of parameters in the request input stream.

2. As part of filter processing the method, Class.writeToMemory() reads the parameters from the input stream.

3. Subsequently the method, Class.setParameters(), calls super.getParameterMap() (in a debug statement). This results in the Web Container request wrapper getParameterMap() being called. This leads to the Web Container trying to read the parameters from the input stream (as it noted in step 1) only to find that they have already been read at step 1. This causes the observed error (post body contains less bytes than specified by content-length).

Because the call that causes the error is in a debug statement, does the problem go away if the debug statement is removed? Also, is this the way the user intends the application to work? The user has written their own request wrapper object and as a result the Web Container request wrapper should not be involved in parsing parameters. 





------解决方案--------------------
Cause 
原因
When a request's HTTP method is POST, the request parameters are sent with 
當一個請求以post方式進行發送時,請求中的參數融合到form中進行提交.
the post form data. If the input stream is read, then the request parameters 
當正在讀取這個請求流時,getParameter("")方法不可用.
are no longer available by way of the getParameter family of methods. The Web 
Container will log the following exception:
當出現上述情況時,web容器會記錄下錯誤信息