• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

printwriter

 
Ranch Hand
Posts: 439
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry i posted this in multiple forums but this just drives me crazy right now. I can't figure out why i can't get an output. Sorry again for post many times. here is the query.
hi i have this method in my code that i wrote to send a message to clients. Now if i change the code to use PrintWriter it says that print writer with every println() method is flushing the buffer it doesn't WORK . i tried everything nothing happends. Now i try to use BufferedWriter same story. I use flush method to flush it nothing happends. I used to specify a buffer size trying to limit it to the length of the string and then flush it again nothing happends. What do i do wrong ? Code is below. The only way it flushes is only when the buffer get's overloaded.
 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
If this is the code in your servlet,then try passing the PrintWriter out as parameter toy uor method.If it is a standalone class I think you will have to import Servlet pacage and use the PrinWriter object as parameter to your method.
 
Val Dra
Ranch Hand
Posts: 439
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
THis is a standalonne class which i start it by command line. Servlets access it and it sends back the data to them well it should. But it doesn't flush it when data arrives.
 
Val Dra
Ranch Hand
Posts: 439
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well it drove me nuts but i got it solved. Not that it was something hard to do but just overlooked HttpServletResponse object which has bufferFlush method. When dealing with more then one Stream it gets tied. I tried to flush on my stream that i get from one of the Server classes which ofcouse didnt' do anything instead must have used HttpServletResponse object. So i post this message just incase someone runs into this.
Thanks and bye
 
Thanks tiny ad, for helping me escape the terrible comfort of this chair.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic