Ben
In the first case the while contains the logic and doesnt allow the program
to exit until until the while condition goes false..
In the second case the try/catch allows the exception to propagate up to the
caller as soon as the exception is caught
Personally I would use the 2nd approach..
Good Catch!!!
Martin-
----- Original Message -----
From: "Ben Souther" <[EMAIL PROTECTED]>
To: "Tomcat Developers List" <[EMAIL PROTECTED]>
Sent: Tuesday, October 12, 2004 3:42 PM
Subject: Re: AW: AW: DefaultServlet and getOutputStream() / getWriter()


> This is the code that I saw (from the beginning of this discussion on
> the user's list).
>
>
> begin quote----------------------------------------------------------
> PS: Since I am already sending another mail, let me append a pending
> question:
>
> I often see code like this in the servlet:
>
> while (...) {
>   try {
>     ...
>   } catch ( ... ) {
>     ...
>   }
> }
>
> which could be replaced with
>
> try {
>   while (...) {
>     ...
>   }
> } catch ( ... ) {
>   ...
> }
>
> which is faster in my imagination.
> Is there a reason or is my imagination false?
> end quote----------------------------------------------------------
>
>
> If the discussion has moved on to something else, then I apologize for
> wasting your time.
>
> -Ben
>
>
>
>
>
> On Tue, 2004-10-12 at 15:31, Steffen Heil wrote:
> > Hi
> >
> > > Compile, run, and view the output from this program.
> > > I think you'll see the difference :o)
> >
> > Sorry, but did you actually read the code it posted?
> > I KNOW that there CAN be a difference in semantics.
> > YOUR code has different semantics.
> >
> > BUT in the code I POSTED there is NONE !
> >
> > So, please read it first.
> >
> > Regards,
> >   Steffen
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to