So, the only real restriction imposed by this part of the spec is that you can't let service() terminate until your other thread is done with ois?
-----Original Message----- From: Christopher K. St. John [mailto:[EMAIL PROTECTED]] Sent: 2001,December.31.Monday 3:19 AM To: [EMAIL PROTECTED] Subject: Re: Applet:Servlet using streams in a thread > Rahul Asanikar wrote: > > public void service(ServletRequest req,ServletResponse res) > { > ... > ois=new ObjectInputStream(req.getInputStream()); ... > r = new receiver(ois); ... > rt.start(); ... > } > > Is there anything which prevents the streams to be > used in a separate thread? > The stream is no longer valid once the service() method finishes. From the 2.3 spec[1]: SRV.4.10 Lifetime of the Request Object Each request object is valid only within the scope of a servlet s service method, ... Containers commonly recycle request objects in order to avoid the performance overhead of request object creation. The developer must be aware that maintaining references to request objects outside the scope described above may lead to non- deterministic behavior. Although it's from the 2.3 spec, it's not a new thing, it's a clarification of how it's always been. So: don't do that. The fact that the request isn't valid outside the service method should get you thinking about how little else you're really sure is valid outside the service method. If a thread references a servlet, and the servlet has been unloaded by the container, does it make a sound? [1] Blah Blah Spec is available at: http://java.sun.com/products/servlet/download.html Download the spec. Read the spec. Obey the spec. All hail the spec. Really, honestly, I swear, it's very easy to read and just about the bestest friend a developer could ever want. -- Christopher St. John [EMAIL PROTECTED] DistribuTopia http://www.distributopia.com ________________________________________________________________________ ___ 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 ___________________________________________________________________________ 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