Re: [Simpleweb-Support] Chat
Brought to you by:
niallg
|
From: berni <be...@t0...> - 2004-04-29 18:33:52
|
Wow! Thank you very much.
This works....
Regards
Bernhard
----- Original Message -----
From: "Niall Gallagher" <nia...@an...>
To: <sim...@li...>
Sent: Tuesday, April 27, 2004 1:36 PM
Subject: Re: [Simpleweb-Support] Chat
> Hi,
>
> Yes, this will not work as the java.io.PrintStream class does not throw
> exceptions. Instead you can either add the code
>
> if(out.checkError()) {
> System.err.println("The client has closed the connection");
> return;
> }
>
> Or you can wrap the OutputStream in somthing that does propagate
> exceptions like the OutputStreamWriter.
>
> Writer out = new OutputStreamWriter(resp.getOutputStream());
>
> Hope this helps.
> Niall
>
> > Hi Niall,
> >
> > it does not work.
> > My Thread just continues forever...
> > Here is my updated code:
> >
> > resp.set("Content-Type", "text/html");
> > resp.set("Connection", "close");
> > // resp.commit();
> > final PrintStream out = resp.getPrintStream();
> > final OutputStream out2 = resp.getOutputStream();
> > out.println("<html><body><h1>Hello Service</h1>");
> > // fill the browser cache
> > for (int i = 0; i < 3000; i++) out.print(" ");
> > out.print("\n");
> > out.flush();
> > new Thread(new Runnable(){
> > int counter = 0;
> > public void run() {
> > try {
> > while (true)
> > {
> > out.println("Hello World #" + (++counter) + "<br>");
> > out.flush();
> > System.out.println("PRINTING..");
> > Thread.sleep(1000);
> > /*if (counter == 10)
> > {
> > out.close();
> > break;
> > }*/
> > }
> > }catch(Exception e){
> > // ....
> > e.printStackTrace(System.err);
> > }
> > }
> > }).start();
> >
> > Regards
> > Bernhard
> >
> > ----- Original Message -----
> > From: "Niall Gallagher" <nia...@an...>
> > To: <sim...@li...>
> > Sent: Wednesday, April 21, 2004 12:28 PM
> > Subject: Re: [Simpleweb-Support] Chat
> >
> >
> > > Hi,
> > >
> > >
> > > > Is it (technically) possible to get an exception or something if the
> > client
> > > > stops loading the page?
> > >
> > > You should be getting an exception from the OutputStream when the
client
> > > stops loading, you should be getting an IOException from the
> > > OutputStream.write or the OutputStream.flush. Let me know if this does
> > > not work.
> > >
> > > Niall
> > >
> > >
> > >
> > > -------------------------------------------------------
> > > This SF.Net email is sponsored by: IBM Linux Tutorials
> > > Free Linux tutorial presented by Daniel Robbins, President and CEO of
> > > GenToo technologies. Learn everything from fundamentals to system
> > > administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
> > > _______________________________________________
> > > Simpleweb-Support mailing list
> > > Sim...@li...
> > > https://lists.sourceforge.net/lists/listinfo/simpleweb-support
> >
> >
> >
> > -------------------------------------------------------
> > This SF.Net email is sponsored by: IBM Linux Tutorials
> > Free Linux tutorial presented by Daniel Robbins, President and CEO of
> > GenToo technologies. Learn everything from fundamentals to system
> > administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
> > _______________________________________________
> > Simpleweb-Support mailing list
> > Sim...@li...
> > https://lists.sourceforge.net/lists/listinfo/simpleweb-support
> >
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek
> For a limited time only, get FREE Ground shipping on all orders of $35
> or more. Hurry up and shop folks, this offer expires April 30th!
> http://www.thinkgeek.com/freeshipping/?cpg=12297
> _______________________________________________
> Simpleweb-Support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simpleweb-support
|