Link to home
Start Free TrialLog in
Avatar of PaulCaswell
PaulCaswellFlag for United Kingdom of Great Britain and Northern Ireland

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.

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");
      }

Open in new window


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
Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India image

Avatar of PaulCaswell

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("Expires", "0");            

and changed:

response.setHeader("Content-Disposition",...

to

response.setHeader("Content-disposition",...

and that does not solve the problem.

Paul
you can use firebug to check the response headers
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
ASKER CERTIFIED SOLUTION
Avatar of PaulCaswell
PaulCaswell
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I found the answer.