Yes, I tried it.
If I don't let the service method to return it works. I just don't want the
streams to go out of scope.
Most of the examples of applet servlet communication need to create the
URLConnection object everytime I send a object. If I don't let the service
method return (of course on certain conditions & not always), I can send as
many objects as I can with jus one connection.
I hope this should work!!!
Any comments??
Best Regards,
Rahul


----- Original Message -----
From: Christopher K. St. John <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, December 31, 2001 1:48 PM
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

Reply via email to