File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
*
The moose likes Servlets and the fly likes How to determine contentLength Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to determine contentLength" Watch "How to determine contentLength" New topic
Author

How to determine contentLength

Franco Finstad
Greenhorn

Joined: May 02, 2003
Posts: 22
I need to use the response.setContentLength() method in my servlet, but I'm not sure how to determine the content length of the actual data I will be sending. I'm working with a basic struts app.

Any ideas?
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
I am confused. Can't you just check the length?


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12839
    
    5
If you write the data into a ByteArrayOutputStream first, you will be able to use the resulting size() and then write the buffer to the response output stream.

See the java.io package javadocs for details

Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to determine contentLength