Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > Servlets
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Servlets section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Closed Thread
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 16th, 2003, 09:31 AM
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:
Coyotewriter.
{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.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.comm it(InternalOutputBuffer.java:547)
org.apache.coyote.http11.Http11Processor.action(Ht tp11Processor.java:735)
org.apache.coyote.Response.action(Response.java:22 3)
org.apache.coyote.http11.InternalOutputBuffer.doWr ite(InternalOutputBuffer.java:518)
org.apache.coyote.Response.doWrite(Response.java:5 32)
org.apache.coyote.tomcat5.OutputBuffer.realWriteBy tes(OutputBuffer.java:392)
org.apache.tomcat.util.buf.ByteChunk.flushBuffer(B yteChunk.java:439)
org.apache.coyote.tomcat5.OutputBuffer.flush(Outpu tBuffer.java:350)
org.apache.coyote.tomcat5.CoyoteWriter.flush(Coyot eWriter.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.serveR equest(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)





Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Question on reusing code billb VBScript 0 August 18th, 2006 10:39 AM
reusing querys jc188 Beginning PHP 3 April 1st, 2006 02:28 AM
Reusing Images hugh@kmcnetwork.com Classic ASP Basics 0 July 19th, 2004 02:58 PM
Reusing String Arrays cebast Servlets 1 May 28th, 2004 04:11 AM



All times are GMT -4. The time now is 06:02 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.