For the archive: This exception was being thrown due to closing the PrintWriter in the doGet() method. Thanks to Milt and everyone else who responded. -----Original Message----- From: Milt Epstein [mailto:[EMAIL PROTECTED]] Sent: 27 November 2000 15:19 To: [EMAIL PROTECTED] Subject: RE: [SERVLET-INTEREST] java.io.IOException: Socket Closed On Mon, 27 Nov 2000 [EMAIL PROTECTED] wrote: > Thank you for your advice Well, did taking out that close() do the trick? > -----Original Message----- > From: Milt Epstein [mailto:[EMAIL PROTECTED]] > Sent: 24 November 2000 15:57 > To: [EMAIL PROTECTED] > Subject: RE: [SERVLET-INTEREST] java.io.IOException: Socket Closed > > > On Fri, 24 Nov 2000 [EMAIL PROTECTED] wrote: > > > Hello Milt, thank you for your reply. I get this exception every > > time I call my servlet - the servlet works ok, I just can't find an > > explanation for the exception. (I should probably also mention that > > this is my first servlet so apologies in advance if this turns out > > to be something trivial). Is it anything to do with closing the > > PrintWriter possibly? Thanks also for the advice on jswdk - would > > That could be it. The servlet container should take care of > creating/opening/closing the InputStreams/Writers, not the servlets > themselves. Try taking that line out and see what happens. > > Also, you could run into trouble with your use of instance variables > (i.e. your mySearcher, out, and v1 variables), because of the > multi-threaded nature of servlets. It looks like out and v1 are only > used in doGet(), so it should be sufficient to make them local to that > method. mySearcher is used in more than one method, but if it's a > "read only" variable, then it should be OK as an instance variable. > > > you advise that I use Tomcat 3.1 instead? > [ ... ] > > Well, that would depend on what your planned future use of servlets > are. If it's just toy/small projects, it probably doesn't matter > much. If it's larger/more long term projects, then you probably would > want to move to something like Tomcat. Note that I'm not necessarily > saying Tomcat is a great product -- I don't really know, I haven't > used it -- it's just that JSWDK is no longer being developed, and it > implements an old version of the servlet spec. Jakarta/Tomcat is the > official implementation of the spec, and it's under continuous > development. > > Also, note that it's probably better to keep the discussion on the > list. That way, it will be visible to more expertise, so there's more > a chance someone will have an answer. Plus I may throw an initial > idea out there in response, but that doesn't necessarily mean I have > any further suggestions if the first isn't right. > > > > > Here is the html which calls the servlet: > > > > <FORM ACTION="http://localhost:8080/examples/servlet/MyS" METHOD="GET"> > > > > > > Here is my servlet class (this uses classes LDAPSearcher and HTML which I > > have not included): > > > > public class MyS extends HttpServlet > > { > > LDAPSearcher mySearcher; > > PrintWriter out; > > Vector v1; > > > > public void init(ServletConfig config) throws ServletException > > { > > try > > { > > super.init(config); > > mySearcher = new LDAPSearcher(); > > } > > catch(Exception e) > > { > > System.out.println("Exception in init "+e); > > } > > } > > > > public void doGet (HttpServletRequest request,HttpServletResponse > > response) throws ServletException, IOException > > { > > try > > { > > String name = request.getParameter("txtFirst"); > > v1 = mySearcher.getEntry(name); > > HTML h = new HTML("LDAP stuff"); > > h.add(HTML.HEADING,"doGet",true); > > Enumeration enum = v1.elements(); > > > > while (enum.hasMoreElements()) > > { > > String st = (String)enum.nextElement(); > > h.add(HTML.NORMAL,st,true); > > } > > v1.clear(); // empty vector..is this the best way to do this? > > > > h.add(HTML.LINE,"",false); > > h.add(HTML.NORMAL,name,true); > > h.add(HTML.LINE,"",false); > > > > h.add(HTML.NORMAL,"The end",true); > > > > // set content type and other response header fields first > > response.setContentType("text/html"); > > out = response.getWriter(); > > out.println(h.getPage()); > > out.close(); > > } > > catch(Exception e) > > { > > System.out.println("Exception in doGet() + "+e); > > v1.clear(); > > } > > } > > > > > > > > > > > > > > > > > > > > > > -----Original Message----- > > From: Milt Epstein [mailto:[EMAIL PROTECTED]] > > Sent: 23 November 2000 20:04 > > To: [EMAIL PROTECTED] > > Subject: Re: [SERVLET-INTEREST] java.io.IOException: Socket Closed > > > > > > On Thu, 23 Nov 2000, Andrew Fairburn wrote: > > > > > Hello, > > > Apologies for asking this again but has anyone got any explanation > > > for this exception - I'm using jswdk-1.0.1 on NT. Thanks all. > > > > > > Andy > > > > > > HANDLER THREAD PROBLEM: java.io.IOException: Socket Closed > > > java.io.IOException: Socket Closed > > > at > > java.net.PlainSocketImpl.getInputStream(PlainSocketImpl.java:421) > > > at java.net.Socket$1.run(Socket.java:335) > > > at java.security.AccessController.doPrivileged(Native Method) > > > at java.net.Socket.getInputStream(Socket.java:332) > > > at > > > com.sun.web.server.ConnectionHandler.run(ConnectionHandler.java:161) > > > > Is this a consistent exception you're getting, or just something that > > appears every so often in the log files? If the latter, it could just > > mean that the client end connection closed for some reason -- browser > > closed, stopped loading, moved to another page. > > > > BTW, JSWDK is dead-end technology, it's been integrated into the > > Jakarta/Tomcat project within Apache. See: > > > > http://jakarta.apache.org > > > > Milt Epstein > > Research Programmer > > Software/Systems Development Group > > Computing and Communications Services Office (CCSO) > > University of Illinois at Urbana-Champaign (UIUC) > > [EMAIL PROTECTED] > > > > > ___________________________________________________________________________ > > 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 > > > > Milt Epstein > Research Programmer > Software/Systems Development Group > Computing and Communications Services Office (CCSO) > University of Illinois at Urbana-Champaign (UIUC) > [EMAIL PROTECTED] > Milt Epstein Research Programmer Software/Systems Development Group Computing and Communications Services Office (CCSO) University of Illinois at Urbana-Champaign (UIUC) [EMAIL PROTECTED] ___________________________________________________________________________ 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
