Sudhanshu Rawat wrote:
>
> 1) Why does getContentLength() return -1 when the page
> is available?
>
getContentLength() just returns the value of the
"Content-Length" header. If your servlet isn't setting
the Content-Length header, then getContentLength()
will return -1. This is documented in the javadocs
for URLConnection. Try:
http://java.sun.com/j2se/1.3/docs/api/java/net/URLConnection.html#getContentLength()
On the servlet side, the javadocs say:
javax.servlet.http.HttpServlet.doGet()
...
Where possible, set the Content-Length header (with
the ServletResponse.setContentLength(int) method),
to allow the servlet container to use a persistent
connection to return its response to the client,
improving performance. The content length is
automatically set if the entire response fits inside
the response buffer.
So, sometimes you might get lucky and have the content
length set for you, but maybe not. If you're going to be
doing any servlet development, you should probably grab
a local copy of the docs, but they're online at:
http://java.sun.com/products/servlet/2.2/javadoc/
--
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