Duane Morse wrote:
> ?From my experience with sockets, the input stream and output stream are
> probably
> tied to the same socket, and closing the input closes the output too. Then,
> when
> you close the output yourself, you get the exception.
>
> Solution -- let the base class close the streams.
>
> Duane Morse, Eldorado Computing Inc., Phoenix AZ
>
> -----Original Message-----
> From: James Knowles [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, November 14, 2000 9:48 AM
> To: [EMAIL PROTECTED]
> Subject: Re: HANDLER THREAD PROBLEM: java.io.IOException: Socket Closed
>
> I am also getting this... does anybody know how to catch this exception...
>
> This is my code that give this error on the console ... ( I am on NT as well
> (please forgive me... ))
>
> import java.io.*;
> import java.net.*;
> import java.text.*;
> import java.util.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
>
> public class readand extends HttpServlet {
>
> public void doGet(HttpServletRequest request,HttpServletResponse response)
> throws IOException, ServletException
> {
>
> response.setContentType("text/html");
> PrintWriter out = response.getWriter();
> try {
> URL url = new URL("http://www.laserrec.co.uk/Default.asp");
> BufferedReader in = new BufferedReader(new
> InputStreamReader(url.openStream()));
>
> int countit = -1;
> String str;
> while ((str = in.readLine()) != null) {
> out.println(str + "\n");
> }
> in.close();
> } catch (MalformedURLException e) {
> }
> catch (IOException e) {
> out.println("?br?The webserver is down");
> out.println(e);
> }
>
> }
> }
>
> When it returns the page correctly I get all of the java.io.IOExceptions
> even though I thought I would have caught them all with catch (IOException
> e)
>
> Hope this helps explain a bit more of the problem ...
>
> James
>
yes:-) I also remember something from a book I have read -> if you close
your BufferedReader, the *underlying TCP socket* will also be closed.
Bo
Nov.14, 2000
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html