读书人

WebSphere Application Server does n

发布时间: 2012-01-05 22:36:54 作者: rapoo

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容器下信息

读书人网 >J2EE开发

热点推荐