Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error in Servlet/JSP

Status
Not open for further replies.

dvsmas

Programmer
Jun 20, 2001
16
0
0
US
I'm getting IllegalStateException and then i'm getting the following error
"Error during native write operation! Status Code: -1"
in stdout log on the webserver.

Any ideas on how to avoid these errors.

All i'm doing in the servlet is get RequestDispatcher object and forward it to a JSP. There are lot of objects in the request object which have to be read back in JSP for display. Is that creating a problem ?

TIA,


 
Make sure that the Response is not being committed by the Servlet. To ensure this it is good practice to not have the Servlet printing anything to the Response. In any case, if the Servlet is writing to the response than it is going to either be cleared if the response is not committed or throw an IllegalStateException if the response is previously commited.

The request object shouldn't be a problem. You may also look at the code in your JSP. I have run into a problem where I was not properly ended a Custom Tag (forgot the / on the closing tag) and it resulted in a IllegalStateException. Took me a bit to figure that one out because I thought that sort of thing would have been caught at page translation time. I guess it all depends on the JSP Engine.
 
Maybe, before the forward() occurs, you have defined zero buffer for servlet (jsp page directive) or have overflowed 8k default buffer and you have already written bytes out as response. If any bytes have been flushed to browser then you have implicitly commited.
------------------------------------
Servlet 2.3 API read javax.servlet.RequestDispatcher.forward() Is equivalent to <jsp:forward> action.

&quot;forward should be called before the response has been committed to the client (before response body output has been flushed). If the response already has been committed, this method throws an IllegalStateException. Uncommitted output in the response buffer is automatically cleared before the forward.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top