View Single Post
Old December 16th, 2003, 09:31 AM
delboypass delboypass is offline
Registered User
Join Date: Dec 2003
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Storing and reusing PrintWriter

I need to know how to store and reuse a printwriter.
Im trying to build a servlet that is able to PUSH javascript commands back to a designated users browser.
To try and do this, i have saved the users printwriter in hashtable.
When the correct event is sent, the users PrintWriter is retrieved from the Hashtable and the browser is written to.

But this doesnt seem to work.
Does anybody know why or how to get around this?
Any help is appreciated.
The printwriter seems to be of type:
{derrick=org.apache.coyote.tomcat5.CoyoteWriter@24 bfaa}

If i use the flush on this printwriter it seems to generate this error

System.out.println("Is this even working: Receivedevent!!!!!!! "+useroutputstream);
PrintWriter usersout = (PrintWriter)useroutputstream.get("derrick");
usersout.println("Testing received event status"+receivedevent);
usersout.print("<script type=\"text/javascript\">");
usersout.print("receivedEvent('your dinner is ready');");
usersout.flush(); -----> Exception: lbp.LBPServlet.doGet(

I dont know if this is also part of the problem but if i use the .flush(), it seems to start throwing exceptions.

org.apache.coyote.http11.InternalOutputBuffer.comm it(
org.apache.coyote.Response.action( 3)
org.apache.coyote.http11.InternalOutputBuffer.doWr ite(
org.apache.coyote.Response.doWrite( 32)
org.apache.coyote.tomcat5.OutputBuffer.realWriteBy tes(
javax.servlet.http.HttpServlet.service(HttpServlet .java:743)
javax.servlet.http.HttpServlet.service(HttpServlet .java:856)
org.apache.catalina.servlets.InvokerServlet.serveR equest(
javax.servlet.http.HttpServlet.service(HttpServlet .java:743)
javax.servlet.http.HttpServlet.service(HttpServlet .java:856)
filters.ExampleFilter.doFilter( 149)
filters.ExampleFilter.doFilter( 149)