PaulCaswell
asked on
How can I debug a download from a jsp.
Hi All,
I have a problem with my jsp. For some reason the download mechanism has broken and I can't find any tools that will help me track the problem. It has not been tested recently so I can't track down the code change that caused it to break.
The attached code is the critical bit. params.packed will be set if a download is requested, params.xls requests xls format. This all should (I believe) work but it doesn't. No file dialog pops up, it just redisplays the report.
Is there a trick in FireBug I can use to inspect the "Content-Disposition" or something?
Paul
I have a problem with my jsp. For some reason the download mechanism has broken and I can't find any tools that will help me track the problem. It has not been tested recently so I can't track down the code change that caused it to break.
if (params.packed) {
// Save Report stuff
String fileExtension = ".html";
if (params.xls) {
response.setContentType("application/plain");
fileExtension = ".xls";
}
final String fileMid;
if (params.automatic) {
fileMid = "." + DateFormatter.toSavedReportsDatetime(params.now);
}
else {
fileMid = "_" + DateFormatter.toFilenameYYYY_MM_DD_HH_MM_SS(params.now);
}
Log.logln("setHeader: attachment; filename=\"" + reportName + fileMid + fileExtension+"\"");
response.setHeader("Content-Disposition", "attachment; filename=\"" + reportName + fileMid + fileExtension+"\"");
Log.logln("setHeader: done");
}
The attached code is the critical bit. params.packed will be set if a download is requested, params.xls requests xls format. This all should (I believe) work but it doesn't. No file dialog pops up, it just redisplays the report.
Is there a trick in FireBug I can use to inspect the "Content-Disposition" or something?
Paul
ASKER
RE: jguru link:
I have tried contentType of "application/vnd.ms-excel" and it still does not work. "application/plain" has worked in the past.
RE: devx link:
Sorry - site is broken for me. What does it suggest?
RE: Q_22152089
I am not using HSSF so that suggestion is not my issue - however, I did add:
response.setHeader("Cache- Control", "public");
response.setHeader("Pragma ", "public");
response.setHeader("Expire s", "0");
and changed:
response.setHeader("Conten t-Disposit ion",...
to
response.setHeader("Conten t-disposit ion",...
and that does not solve the problem.
Paul
I have tried contentType of "application/vnd.ms-excel"
RE: devx link:
Sorry - site is broken for me. What does it suggest?
RE: Q_22152089
I am not using HSSF so that suggestion is not my issue - however, I did add:
response.setHeader("Cache-
response.setHeader("Pragma
response.setHeader("Expire
and changed:
response.setHeader("Conten
to
response.setHeader("Conten
and that does not solve the problem.
Paul
you can use firebug to check the response headers
ASKER
I'm not at work at the moment so I can't check but my thoughts were that this should be a server-side issue shouldn't it?
If the Content-Disposition is acted on at the client side then certainly I can check the Response headers. What should I look for?
NB: The jsp is a target of a forward (as opposed to a redirect). Could that be my issue?
Paul
If the Content-Disposition is acted on at the client side then certainly I can check the Response headers. What should I look for?
NB: The jsp is a target of a forward (as opposed to a redirect). Could that be my issue?
Paul
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Please see tip 2 at
http://www.oreillynet.com/pub/a/oreilly/java/news/jsptips_1100.html
http://www.oreillynet.com/pub/a/oreilly/java/news/jsptips_1100.html
ASKER
I found the answer.
http://www.jguru.com/faq/view.jsp?EID=1307284
http://www.devx.com/Java/Article/31356/0/page/3
https://www.experts-exchange.com/questions/22152089/A-servlet-to-output-a-xls-file.html