The moose likes Servlets and the fly likes Unexpected command 31 when accessing a ServletInputStream Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Unexpected command 31 when accessing a ServletInputStream" Watch "Unexpected command 31 when accessing a ServletInputStream" New topic

Unexpected command 31 when accessing a ServletInputStream

Sylvain Mainguy

Joined: Jan 24, 2002
Posts: 5
I'm trying to post a file to a servlet.
Everything seems to be ok on application side, but the servlet doesn't work very well.
In the doPost method, I get the headers from the HttpServletRequest (filename, contentlength,...) and then get the inputStream. Headers contents are correct.
I try to write what comes from the inputStream (wrapped in a BufferedInputStream) to a FileOutputStream (wrapped in a BufferedOutputStream). When all is done, I would like to send a special status code (like 209) that means the file has been saved correctly and fully on the server. But the servlet seems to have problems. Since I get the inputStream, it often crash with an IOException "Unexpected command 31". (stack follows)
I don't understand why, I don't know what is wrong with my code. (see http://www.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=7&t=007313)
Help me please. Thanks.

Kathy Hale

Joined: Jan 24, 2007
Posts: 5
I've had something similiar also when posting a file to a servlet. This time, the code works on one implementation of ColdFusion/JRun and not on another. I get a different error number, but the problem sounds very familiar.

Here's the code that was calling it. I was using Commons FileUpload 1.2 and Commons IO 1.3.1. Servlet.jar came from Apache because JRun does not provide one strangely enough. Note, this servlet has a get and a post - the get works fine.

jQuery in Action, 2nd edition
subject: Unexpected command 31 when accessing a ServletInputStream
Similar Threads
Class cast exception
java.io.IOException: Broken pipe when dispatching page
Posting a file to a servlet
Jrun needs daily restart or JavaMail fails
"Current thread not owner" on upload.parseRequest(request);