DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18979>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18979
Sample FileUpload application fails on z/OS platform
------- Additional Comments From smamindl@us.ibm.com 2003-04-29 14:18 -------
Here is what I found out about the reasons why it is not working on z/OS WAS
4.0.1. When the WAS 4.0.1 on z/OS comes up it comes up on EBCIDIC JVM as
apposed to the ASCII JVM. But when you make a request from the browser the
content gets in the ASCII format on to the server side. Any operations that are
done on this content cannot be done by defaulting to the JVM code page(it is
EBCIDIC in z/OS). Luckily this is changing in WAS 5.0 for z/OS. The JVM comes
up in ASCII.
For example in org.apache.commons.fileupload.FileUpload.java in the method
public List /* FileItem */ parseRequest(HttpServletRequest req, int
sizeThreshold, int sizeMax, String path) there is a line where it gets the byte
[] by doing the getBytes(). Since there is no codepage argument has been passed
to the getBytes() method it is defaulting to the JVM code page. In z/OS case it
is EBCIDIC and it is trying to manipulate the ASCII content. Hence there is a
conflict.
I found total of three programs where it is doing the similar thing. There
could be more places where a similar thing could have been done but I do not
know.
Program Name : org.apache.commons.fileupload.FileUpload.java
Method Name : public List /* FileItem */ parseRequest(HttpServletRequest req,
int sizeThreshold, int sizeMax, String path)
problem code :
byte[] boundary = contentType.substring(contentType.indexOf("boundary=") +
9).getBytes();
Suggestion:
byte[] boundary = contentType.substring(contentType.indexOf("boundary=") +
9).getBytes("8859_1");
Program Name: org.apache.commons.fileupload.MultipartStream.java
Method Name: public String readHeaders() throws MalformedStreamException
problem code:
return baos.toString();
Suggestion:
String s = null;
try {
s = baos.toString("8859_1");
} catch (Exception e) {
e.printStackTrace();
}
return s;
Program Name:
org.apache.struts.upload.CommonsMultipartRequestHandler.java
Method Name:
protected void addTextParameter(HttpServletRequest request, FileItem item)
problem code:
try {
value = item.getString(request.getCharacterEncoding());
} catch (Exception e) {
value = item.getString();
}
Suggestion:
try {
value = item.getString(request.getCharacterEncoding());
} catch (Exception e) {
try {
value = item.getString("8859_1");
} catch(Exception e1){
value = item.getString();
}
}
These changes have worked except that there is one more change required in the
sample .war file to display the characters read from the file to display
correctly.
Program Name: org.apache.struts.webapp.upload.UploadAction.java
Method Name:public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception
Problem code: data = new String(baos.toByteArray());
Suggestion: data = new String(baos.toByteArray(), "8859_1");
Please can somebody look at this problem and provide us a fix.
Thanks.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
|