that's exactly what I thought, but apparently Brian meant that two
BufferedInputStream objects cannot access the same file simultaneously.
Meaning, it is the file that is actually synched, not the Stream object...
zm.


-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Christopher K. St. John
Sent: Wednesday, January 16, 2002 2:26 AM
To: [EMAIL PROTECTED]
Subject: Re: Downloading files with jsp/servlets...


Brian Bohnet wrote:
>
> one of our developers decided to investigate the source
> of the BufferInputStream class instead. Finding everything to be
> synchronized gave him the idea to write his own class removing
> synchronization, and allowing the server to handle the bandwidth and
> threading, instead of relying on the single instance of the servlet.
>

 Wait a second, there's something wrong here. Serving static
files from a servlet is a very common thing to do. Generally
the code looks something like:

 public void doGet() {
   ...
   InputStream istr =
     new BufferedInputStream(new FileInputStream("some_file.txt"));
   ... loop around writing istr to rsp output stream ...
 }

 Is that what you're talking about? If not, then never mind,
I've misunderstood your situation.

 If so, then synchronization on BufferedInputStream is not
your problem. It can't be, since each servlet thread gets its
own BufferedInputStream. Besides, the code works fine for
everybody else.

 Are you trying to share the BufferedInputStream? or the
FileInputStream? Do you have a synchronized block in some
of your servlet code? Have you accidently set your servlet
container to allow only a very few simultaneous threads?
Etc, etc.

--
Christopher St. John [EMAIL PROTECTED]
DistribuTopia http://www.distributopia.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to