[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: servlet multiple loops, help please...



Well, in general I treat the User-Agent=contype GET just like I would a 
HEAD request (that is, write out the headers but no body).  Why MS uses 
this method instead of a HEAD request is a mystery to me, but I digress.

I recall there being some difference in the headers sent in the first 
and last requests, but can't recall off the top of my head which headers 
specifically.  I suggest dumping all of the headers out to the console 
to find the difference.

If your desired workflow allows it, you can avoid the multiple requests 
alltogether by generating an HTML page with an embedded OBJECT tag for 
the PDF; IE only makes a single request for the content if Acrobat is 
loaded in this way.

When you get all of this worked out, you'll want to seriously consider 
byteserving the PDF to Acrobat.  You get major improvements in the user 
experience.  If this isn't familiar to you, don't worry about it.

Lynn Young wrote:
> Then how to handle it?  or there is no way?
> 
>  */Brian Sanders <brian.j.sanders@mindspring.com>/* wrote:
> 
>     You're seeing the servlet output 3 times because 3 separate requests
>     are
>     being made. If you use IE 5.5, you'll see 2 requests. This is the way
>     Internet Explorer behaves when loading content with a plug-in.
> 
>     For request #1, IE reads the content type to be PDF, so it closes that
>     connection immediately. Then, it sends another request where the
>     User-Agent header has the value "contype". The only thing you have to
>     return for this request is the Content-Type header (e.g., call
>     response.setContentType("application/pdf") then output nothing in the
>     body). The third request is actually from the plug-in.
> 
>      > And the output of this servlet is:
>      >
>      > 0
>      >
>      > 0
>      >
>      > 0
>      >...
>      >
>      > Another thing I notices is that: if I comment the following code:
>      >
>      > response.setContentType("application/pdf");
>      >
>      > then the problem is gone. I use PDF format because I am using
>     iText tool
>      > to general pdf file and print it. Is it possible that since it takes
>      > some time to open acrobat reader, it generates multiple threads by
>      > itself? I call the servlet directly from the location bar of the
>      > Internet Explorer.

-- 
Brian Sanders
Java Developer