Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

setHeader method in JAVA

Posted on 2000-02-18
5
Medium Priority
?
376 Views
Last Modified: 2012-08-13
How can I add the size of the file to my headers so that people downloading my .rtf files will know how large the files are?

the following code is what I have so far:

setHeader("Content-disposition", "attachment;filename=" + reportType + ".rtf");

is adding  ";filesize=" + filename.size() even close to an answer?

0
Comment
Question by:jerelw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 5

Accepted Solution

by:
mbormann earned 300 total points
ID: 2536636
I think it's Content-Length, I think that before you write anything to the stream,set it with the correct Length you are going to write.

Note that thsi is the way of specifying persistemt connections (also called as Keep Alive)

Read for basics
http://www-4.ibm.com/software/webservers/appserv/doc/v20dcadv/doc/readme.txt

code
http://www.servletforum.com/sf/1999/Nov/941724512594.html
0
 
LVL 3

Author Comment

by:jerelw
ID: 2538553
i'll try it, for a bonus, how do i get the file size if the report is created at runtime?
0
 
LVL 5

Expert Comment

by:mbormann
ID: 2541249
was away on leave ,but the file size is always got at runtime.I don't understand what you mean to say.
0
 
LVL 3

Author Comment

by:jerelw
ID: 2542445
is there a method called getSize() that would return an int of my file in bytes?

for example,

File f = new File("myFile");
int size = f.getSize();

and then in my header I can specify my file size by entering:

content-length: size }
0
 
LVL 5

Expert Comment

by:mbormann
ID: 2542480
int size = (int)f.length();
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question