users@glassfish.java.net

Re: Problem in posting data of large size

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Wed, 25 Jun 2008 10:45:33 -0400

Salut,

glassfish_at_javadesktop.org wrote:
> I use ExtJS 2.0.2 to build my web UI and it's Ajax.request function to post data in json format to glassfish server. A problem really confused me and nearly drove me crazy. After data(Chinese characters) of large size was posted from client, when I read them from request input stream, some characters became unrecognized. for example:
> int contentLength = request.getContentLengt();
> byte[] bytes = new byte[contentLength];
> int bytesRead = -1;
> InputStream is = request.getInputStream();
> ByteArrayOutputStream baos = new ByteArrayOutputStream(contentLength);
> while((bytesRead = is.read(bytes,0,contentLength) != -1) {
> baos.write(bytes,0,bytesRead);
> }
> String value = new String(baos.toArray(),"UTF-8");
> most(99%) of characters(Chinese characters) in the variable value are correct, but a few characters became '\ufffd', meaning some byte sequence that unicode doesn't know appeared. I used Fiddler to capture data post from client and was sure that data was encoded correctly, so the problem must exist in the process of request processing. By the way, I use UTF-8 everywhere so it shouldn't be caused by incorrect encoding conversions.
> I thought maybe it's glassfish's bug of failing to decoding characters from input stream correctly,but after I substituted Jetty for glassfish the same problem happened. Then I changed glassfish's parameter: receive buffer size of connection pool in http services,say, from 8192 to 819200, everything seems ok (I'm not quite sure). So I guess maybe it's because data post was too large for receive buffer(some data post was of size more than 80000 bytes),so during process some characters were just truncated or something else happened? What happened when I post large data, say, as many as 80000 bytes to server? Thanks!
>

Can you file an issue here:

https://glassfish.dev.java.net/servlets/ProjectIssues

I suspect there is a buffer size problem when we do the conversion. If
you can attach a test case, that would be perfect!

Thanks!

-- Jeanfrancois



  [Message sent by forum member 'cppasm' (cppasm)]
>
> http://forums.java.net/jive/thread.jspa?messageID=282514
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>