Hello :-) Does anybody knows if the described below problem is a Servlet's API bug, or maybe I make a mistake? And... how to solve it?
I work on Windows 2000, the Java version is J2SE 1.4.0, and I use CodeGuide 4.0 for running my servlet's application. Into the servlet's init() method I create an instance of a class which plays a role as an engine for processing the client's requests, and into the doPost(...) method I invoke relative (to the clients requests) methods from the engine's instance. One of the engine's fields is a Hashtable object, which the clients populate with concrete requests. In one of the engine's methods it is needed to to wait (using the wait( some_time ) ) for someone to fill into the Hashtable's object. And, here is the problem: If a client, which request is into the described above engine's method, is been dropped down (unexpectedly), then after elapsing the waited time, the next exception occurs (and it cannot be caught in try/catch block): ------------------------------------------------------ java.lang.IllegalStateException: Current state = FLUSHED, new state = CODING_END at java.nio.charset.CharsetEncoder.throwIllegalStateException(CharsetEncoder.java:933) at java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:529) at sun.nio.cs.StreamEncoder$CharsetSE.flushLeftoverChar(StreamEncoder.java:356) at sun.nio.cs.StreamEncoder$CharsetSE.implClose(StreamEncoder.java:413) at sun.nio.cs.StreamEncoder.close(StreamEncoder.java:158) at java.io.OutputStreamWriter.close(OutputStreamWriter.java:222) at java.io.PrintWriter.close(PrintWriter.java:137) at org.apache.catalina.connector.ResponseBase.finishResponse(ResponseBase.java:482) at org.apache.catalina.connector.HttpResponseBase.finishResponse(HttpResponseBase.java:236) at org.apache.catalina.connector.http.HttpResponseImpl.finishResponse(HttpResponseImpl.java:288) at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1039) at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1107) at java.lang.Thread.run(Thread.java:536) ----------------------------------------------------------- And if needed, here is the engine's method: ---------------------------- public String getRequests(long parentPID, String forUser, String userId, HttpServletRequest httpReq) { String result; try { ........ result = BChatConstants.GET_REQUESTS_REPLY + "\n"; Hashtable requests = null; synchronized (requests = (Hashtable) requestedData.get(forUser)) { // here requestedData is Hashtable too if (requests.isEmpty()){ requests.wait(30000); } if (requests.isEmpty()) { ......... } else { ......... ......... } } return result; }catch (Exception e) { e.printStackTrace(); } return result; } ---------------------------- Thanks, Lyubomir. ___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST". Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html