wood burning stoves 2.0*
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

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to determine contentLength" Watch "How to determine contentLength" New topic

How to determine contentLength

Franco Finstad

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?

So much trouble in the world -- Bob Marley
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12759
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

I agree. Here's the link: http://aspose.com/file-tools
subject: How to determine contentLength
Similar Threads
JCheckBox Question
ip address ?
Class output directory ni SunOne EE
Controlling Button Focus with Arrow Keys