You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by de...@bt.com on 2003/12/16 16:12:25 UTC

Having problems with stored PrintWriter.

Im having a problem with PrintWriter in a servlet.
 
I am trying to store users PrintWriter and use them again at a later date to output javascript commands to the browsers at a later date. it store as a coyotewriter - org.apache.coyote.tomcat5.CoyoteWriter@24bfaa
 
To do this they are dumped in a hashtable. But they dont seem to work when i try to write output with them? Is there any way around this??
 
this is the error I get but only when i include the flush() line. 
 
If anybody can help it would be most appreciated
 
To write out to users browser - retrieves from hashtable
--------------------------------------------
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.print("</script>");
//extraline
usersout.flush(); -----> Exception: lbp.LBPServlet.doGet(LBPServlet.java:98)

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

java.lang.NullPointerException
org.apache.coyote.http11.InternalOutputBuffer.commit(InternalOutputBuffer.java:547)
org.apache.coyote.http11.Http11Processor.action(Http11Processor.java:735)
org.apache.coyote.Response.action(Response.java:223)
org.apache.coyote.http11.InternalOutputBuffer.doWrite(InternalOutputBuffer.java:518)
org.apache.coyote.Response.doWrite(Response.java:532)
org.apache.coyote.tomcat5.OutputBuffer.realWriteBytes(OutputBuffer.java:392)
org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:439)
org.apache.coyote.tomcat5.OutputBuffer.flush(OutputBuffer.java:350)
org.apache.coyote.tomcat5.CoyoteWriter.flush(CoyoteWriter.java:119)
lbp.LBPServlet.doGet(LBPServlet.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:466)
org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:180)
javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
filters.ExampleFilter.doFilter(ExampleFilter.java:149)
filters.ExampleFilter.doFilter(ExampleFilter.java:149)

Re: Having problems with stored PrintWriter.

Posted by Ben Souther <bs...@fwdco.com>.
> I am trying to store users PrintWriter and use them again at a later date
Just out of curiosity, why?




On Tuesday 16 December 2003 10:12 am, derrick.robertson@bt.com wrote:
> Im having a problem with PrintWriter in a servlet.
>
> I am trying to store users PrintWriter and use them again at a later date
> to output javascript commands to the browsers at a later date. it store as
> a coyotewriter - org.apache.coyote.tomcat5.CoyoteWriter@24bfaa
>
> To do this they are dumped in a hashtable. But they dont seem to work when
> i try to write output with them? Is there any way around this??
>
> this is the error I get but only when i include the flush() line.
>
> If anybody can help it would be most appreciated
>
> To write out to users browser - retrieves from hashtable
> --------------------------------------------
> 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.print("</script>");
> //extraline
> usersout.flush(); -----> Exception:
> lbp.LBPServlet.doGet(LBPServlet.java:98)
>
> I dont know if this is also part of the problem but if i use the .flush(),
> it seems to start throwing exceptions.
>
> java.lang.NullPointerException
> org.apache.coyote.http11.InternalOutputBuffer.commit(InternalOutputBuffer.j
>ava:547)
> org.apache.coyote.http11.Http11Processor.action(Http11Processor.java:735)
> org.apache.coyote.Response.action(Response.java:223)
> org.apache.coyote.http11.InternalOutputBuffer.doWrite(InternalOutputBuffer.
>java:518) org.apache.coyote.Response.doWrite(Response.java:532)
> org.apache.coyote.tomcat5.OutputBuffer.realWriteBytes(OutputBuffer.java:392
>) org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:439)
> org.apache.coyote.tomcat5.OutputBuffer.flush(OutputBuffer.java:350)
> org.apache.coyote.tomcat5.CoyoteWriter.flush(CoyoteWriter.java:119)
> lbp.LBPServlet.doGet(LBPServlet.java:98)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
> org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.jav
>a:466)
> org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:180)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
> filters.ExampleFilter.doFilter(ExampleFilter.java:149)
> filters.ExampleFilter.doFilter(ExampleFilter.java:149)

-- 
Ben Souther
F.W. Davison & Company, Inc.



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org