So I just upgraded my app to Struts 2.2.1, from 2.0.something. I made the 
camelCase changes, added in the missing libs, and fired it up. All seems to be 
working as expected, except the results of type "stream". Im not sure why, but 
it will not stream anything to the browser. This is my config:

<action name="exportSelectedProject" class=" action.ExportAction"
                  method="exportSelected">
                  <result name="success" type="stream">
                        <param 
name="contentType">application/vnd.ms-excel</param>
                        <param name="inputName">excelStream</param>
                        <param 
name="contentDisposition">attachment;filename="ProjectExport.xls"</param>
                        <param name="bufferSize">1024</param>
                  </result>
            </action>

Is there anything blatantly wrong with this configuration?

This is the relevant action code:

public class ExportAction extends BaseAction {
      private static final long serialVersionUID = 1965787242344910138L;
      private List<Project> projects;
      private InputStream excelStream;
      private ProjectSearch search;
      private Integer contentLength;

      public String exportSelected() {
            Workbook export = null;
            try {
                  export = ExportService.createHSSFExport(projects);
            } catch (SQLException e1) {
                  logger.error("Error while creating export", e1);
                  addActionError("An error occurred while attempting to create 
the export");
            }
            try {
                  ByteArrayOutputStream out = new ByteArrayOutputStream();
                  export.write(out);
                  excelStream = new ByteArrayInputStream(out.toByteArray());
                  contentLength = excelStream.available();
                  logger.info("CONTENT LENGTH: " + contentLength);
            } catch (IOException e) {
                  logger
                              .error(
                                          "Error occured while trying to write 
the export to an OutputStream",
                                          e);
                  addActionError("An error occurred while attempting to create 
the export");
            }
            return SUCCESS;
      }

All the above fields have their getters/setters. I have struts debug turned on 
as well. I get no error messages. It runs the ExportService.createHSSFExport() 
just fine, but doesn't stream it out for some reason. Anyone else run into this?

-Ryan

________________________________
This communication is the property of Qwest and may contain confidential or
privileged information. Unauthorized use of this communication is strictly
prohibited and may be unlawful. If you have received this communication
in error, please immediately notify the sender by reply e-mail and destroy
all copies of the communication and any attachments.

Reply via email to