Commits

Anonymous committed eae09a2

* random bug fixes
* switched to a jasper result rather than a servlet

git-svn-id: http://svn.opensymphony.com/svn/webwork/trunk@394573baa09-0c28-0410-bef9-dab3c582ae83

Comments (0)

Files changed (11)

src/etc/example/i18n.xml

             <result name="success" type="velocity">
                 <param name="location">shop.vm</param>
             </result>
-            <result name="error" type="dispatcher">
+            <result name="error" type="velocity">
                 <param name="location">language.vm</param>
             </result>
         </action>

src/etc/example/xwork.xml

         <action name="basicValidation" class="com.opensymphony.webwork.example.ValidatedAction">
             <interceptor-ref name="validationWorkflowStack"/>
 
-            <result name="success" type="dispatcher">valid.vm</result>
-            <result name="input" type="dispatcher">validationForm.vm</result>
-            <result name="error" type="dispatcher">validationForm.vm</result>
+            <result name="success" type="velocity">valid.vm</result>
+            <result name="input" type="velocity">validationForm.vm</result>
+            <result name="error" type="velocity">validationForm.vm</result>
         </action>
 
         <action name="visitorValidation" class="com.opensymphony.webwork.example.ValidatedAction">
             <interceptor-ref name="validationWorkflowStack"/>
             <param name="validationAction">visitorValidation.action</param>
-            <result name="success">valid.vm</result>
-            <result name="input">validationForm.vm</result>
-            <result name="error">validationForm.vm</result>
+            <result name="success" type="velocity">valid.vm</result>
+            <result name="input" type="velocity">validationForm.vm</result>
+            <result name="error" type="velocity">validationForm.vm</result>
         </action>
 
         <action name="expressionValidation" class="com.opensymphony.webwork.example.ValidatedAction">
             <interceptor-ref name="validationWorkflowStack"/>
             <param name="validationAction">expressionValidation.action</param>
             <param name="bean.number2">15</param>
-            <result name="success">valid.vm</result>
-            <result name="input">validationForm.vm</result>
-            <result name="error">validationForm.vm</result>
+            <result name="success" type="velocity">valid.vm</result>
+            <result name="input" type="velocity">validationForm.vm</result>
+            <result name="error" type="velocity">validationForm.vm</result>
         </action>
 
         <action name="javascriptValidation" class="com.opensymphony.webwork.example.JavascriptValidationAction">
 
 		 <!-- JasperReport Basic Test Actions -->
         <action name="jasperTest" class="com.opensymphony.webwork.example.jasperreports.OrderListAction">
-            <param name="dataSource">orders</param>
-            <result name="success" type="dispatcher">
+            <result name="success" type="jasper">
                 <param name="location">orderList.jasper</param>
+                <param name="dataSource">orders</param>
             </result>
             <interceptor-ref name="defaultStack"/>
         </action>
 
         <action name="jasperPDFTest" class="com.opensymphony.webwork.example.jasperreports.OrderListAction">
-            <param name="dataSource">orders</param>
-            <param name="format">PDF</param>
-            <result name="success" type="dispatcher">
+            <result name="success" type="jasper">
                 <param name="location">orderList.jasper</param>
+                <param name="dataSource">orders</param>
+                <param name="format">PDF</param>
             </result>
             <interceptor-ref name="defaultStack"/>
         </action>
 
         <action name="jasperCSVTest" class="com.opensymphony.webwork.example.jasperreports.OrderListAction">
-            <param name="dataSource">orders</param>
-            <param name="format">CSV</param>
-            <result name="success" type="dispatcher">
+            <result name="success" type="jasper">
                 <param name="location">orderList.jasper</param>
+                <param name="dataSource">orders</param>
+                <param name="format">CSV</param>
             </result>
             <interceptor-ref name="defaultStack"/>
         </action>
         <action name="jasperHTMLTest" class="com.opensymphony.webwork.example.jasperreports.OrderListAction">
-            <param name="dataSource">orders</param>
-            <param name="format">HTML</param>
-            <result name="success" type="dispatcher">
+            <result name="success" type="jasper">
                 <param name="location">orderList.jasper</param>
+                <param name="dataSource">orders</param>
+                <param name="format">HTML</param>
             </result>
             <interceptor-ref name="defaultStack"/>
         </action>
         <action name="jasperXLSTest" class="com.opensymphony.webwork.example.jasperreports.OrderListAction">
-            <param name="dataSource">orders</param>
-            <param name="format">XLS</param>
-            <result name="success" type="dispatcher">
+            <result name="success" type="jasper">
                 <param name="location">orderList.jasper</param>
+                <param name="dataSource">orders</param>
+                <param name="format">XLS</param>
             </result>
             <interceptor-ref name="defaultStack"/>
         </action>
         <action name="jasperXMLTest" class="com.opensymphony.webwork.example.jasperreports.OrderListAction">
-            <param name="dataSource">orders</param>
-            <param name="format">XML</param>
-            <result name="success" type="dispatcher">
+            <result name="success" type="jasper">
                 <param name="location">orderList.jasper</param>
+                <param name="dataSource">orders</param>
+                <param name="format">XML</param>
             </result>
             <interceptor-ref name="defaultStack"/>
         </action>

src/example/com/opensymphony/webwork/example/jasperreports/OrderListAction.java

  */
 package com.opensymphony.webwork.example.jasperreports;
 
-import com.opensymphony.webwork.views.jasperreports.JasperReportAction;
+import com.opensymphony.xwork.ActionSupport;
 
 import java.io.BufferedReader;
 import java.io.InputStream;
 import java.io.InputStreamReader;
-
 import java.util.ArrayList;
 import java.util.List;
 import java.util.StringTokenizer;
  * @author &lt;a href="hermanns@aixcept.de"&gt;Rainer Hermanns&lt;/a&gt;
  * @version $Id$
  */
-public class OrderListAction extends JasperReportAction {
+public class OrderListAction extends ActionSupport {
     //~ Static fields/initializers /////////////////////////////////////////////
 
     // Attributes ----------------------------------------------------
         }
     }
 
-    public OrderListAction() {
-        setDataSource("orders");
-    }
     //~ Methods ////////////////////////////////////////////////////////////////
 
     public Object[] getOrderArray() {

src/java/com/opensymphony/webwork/dispatcher/VelocityResult.java

 
 import com.opensymphony.webwork.ServletActionContext;
 import com.opensymphony.webwork.views.velocity.VelocityManager;
-import com.opensymphony.webwork.views.velocity.WebWorkVelocityServlet;
-
 import com.opensymphony.xwork.ActionContext;
 import com.opensymphony.xwork.ActionInvocation;
 import com.opensymphony.xwork.util.OgnlValueStack;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-
 import org.apache.velocity.Template;
 import org.apache.velocity.app.VelocityEngine;
 import org.apache.velocity.context.Context;
 import org.apache.velocity.runtime.RuntimeSingleton;
-
-import java.io.Writer;
+import org.apache.velocity.servlet.VelocityServlet;
 
 import javax.servlet.Servlet;
-import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.jsp.JspFactory;
 import javax.servlet.jsp.PageContext;
+import java.io.Writer;
 
 
 /**
             Context context = createContext(velocityManager, stack, request, response, finalLocation);
             Writer writer = pageContext.getOut();
 
-            // @todo can t.getEncoding() ever return a null value?
-            String encoding = RuntimeSingleton.getString(RuntimeSingleton.OUTPUT_ENCODING, WebWorkVelocityServlet.DEFAULT_OUTPUT_ENCODING);
+            String encoding = RuntimeSingleton.getString(RuntimeSingleton.OUTPUT_ENCODING, VelocityServlet.DEFAULT_OUTPUT_ENCODING);
 
             if (usedJspFactory) {
                 if (encoding != null) {

src/java/com/opensymphony/webwork/views/jasperreports/JasperReportAction.java

-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.webwork.views.jasperreports;
-
-import com.opensymphony.webwork.ServletActionContext;
-
-import com.opensymphony.xwork.ActionSupport;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-
-/**
- * <code>JasperReportAction</code>
- *
- * @author <a href="mailto:hermanns@aixcept.de">Rainer Hermanns</a>
- * @version $Id$
- */
-public class JasperReportAction extends ActionSupport implements JasperReportConstants {
-    //~ Static fields/initializers /////////////////////////////////////////////
-
-    /** jakarta-commons-logging reference */
-    private final static Log log = LogFactory.getLog(JasperReportAction.class);
-
-    //~ Instance fields ////////////////////////////////////////////////////////
-
-    /** data source static param */
-    private String dataSource;
-
-    /** format static param */
-    private String format;
-
-    //~ Methods ////////////////////////////////////////////////////////////////
-
-    /**
-     * Sets the dataSource for the requested report from the static params.
-     *
-     * @param dataSource - datasource attribute from static params
-     */
-    public void setDataSource(String dataSource) {
-        this.dataSource = dataSource;
-    }
-
-    /**
-     * Returns the dataSource for the requested report from the static params.
-     *
-     * @return dataSource - datasource attribute from static params
-     */
-    public String getDataSource() {
-        return dataSource;
-    }
-
-    /**
-     * Sets the output format of the report.
-     *
-     * @param format - the output format of the report.
-     */
-    public void setFormat(String format) {
-        this.format = format;
-    }
-
-    /**
-     * Returns the output format of the report.
-     *
-     * @return format - the output format of the report.
-     */
-    public String getFormat() {
-        return format;
-    }
-
-    /**
-     * Sets the static params format and dataSource from static params as request attributes and forwards to the
-     * JasperReportViewServlet.
-     *
-     * @return SUCCESS, if all parameters are given, ERROR otherwise
-     * @throws Exception
-     */
-    public String execute() throws Exception {
-        super.execute();
-
-        if (format == null) {
-            format = FORMAT_PDF;
-        }
-
-        if (dataSource == null) {
-            addActionError("No datasource was specified...");
-
-            if (log.isErrorEnabled()) {
-                log.error("JasperReportAction - [execute]: No dataSource specified...");
-            }
-
-            return ERROR;
-        }
-
-        if (log.isDebugEnabled()) {
-            log.debug("JasperReportAction - [execute]: Creating JasperReport for dataSource=" + dataSource + ", format=" + format);
-        }
-
-        ServletActionContext.getRequest().setAttribute("dataSource", dataSource);
-        ServletActionContext.getRequest().setAttribute("format", format);
-
-        // Forward to the next page
-        return SUCCESS;
-    }
-}

src/java/com/opensymphony/webwork/views/jasperreports/JasperReportViewServlet.java

-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.webwork.views.jasperreports;
-
-import com.opensymphony.webwork.ServletActionContext;
-
-import com.opensymphony.xwork.util.OgnlValueStack;
-
-import dori.jasper.engine.*;
-import dori.jasper.engine.export.*;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.servlet.ServletException;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-
-/**
- * Provide a view of a webwork action as a jasper report. The report format will be determined by
- * the format parameter passed in the xwork action definition.
- * Example action definition:
- *
- * &lt;action name="jasperTest" class="com.opensymphony.webwork.views.jasperreports.example.OrderListAction"&gt;
- *    &lt;param name="dataSource"&gt;orders&lt;/param&gt;
- *    &lt;param name="format"&gt;PDF&lt;/param&gt;
- *    &lt;result name="success" type="dispatcher"&gt;
- *        &lt;param name="location"&gt;orderList.jasper&lt;/param&gt;
- *    &lt;/result&gt;
- *    &lt;interceptor-ref name="defaultStack"/&gt;
- * &lt;/action&gt;
- *
- * Valid report format strings are the following:
- * &lt;ul&gt;
- * &lt;li&gt;PDF&lt;/li&gt;
- * &lt;li&gt;XML&lt;/li&gt;
- * &lt;li&gt;HTML&lt;/li&gt;
- * &lt;li&gt;XLS&lt;/li&gt;
- * &lt;li&gt;CSV&lt;/li&gt;
- * &lt;/ul&gt;
- * It will then look for a compiled report definition of the form &lt;code&gt;&lt;view name&gt;.jasper&lt;/code&gt;,
- * run it to the appropriate output format and stream the results as the HTTP response.
- *
- * Ported to WebWork2:
- *
- * @author &lt;a href="hermanns@aixcept.de"&gt;Rainer Hermanns&lt;/a&gt;
- * @version $Id$
- */
-public class JasperReportViewServlet extends HttpServlet implements JasperReportConstants {
-    //~ Static fields/initializers /////////////////////////////////////////////
-
-    protected static Log log = LogFactory.getLog(JasperReportViewServlet.class);
-
-    //~ Instance fields ////////////////////////////////////////////////////////
-
-    protected String IMAGES_URI = "/images/";
-
-    //~ Methods ////////////////////////////////////////////////////////////////
-
-    /* (non-Javadoc)
-     * @see javax.servlet.GenericServlet#init()
-     */
-    public void init() throws ServletException {
-        super.init();
-
-        if (getServletConfig().getInitParameter("IMAGES_URI") != null) {
-            IMAGES_URI = getServletConfig().getInitParameter("IMAGES_URI");
-        }
-    }
-
-    /**
-    * Service a HTTP request
-    * @param request the request to service
-    * @param response the response to send to the client
-    */
-    public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException {
-        String imageName = request.getParameter("image");
-
-        //load image from IMAGES_MAP
-        if (imageName != null) {
-            Map imagesMap = (Map) request.getSession().getAttribute("IMAGES_MAP");
-
-            if (imagesMap != null) {
-                byte[] imageData = (byte[]) imagesMap.get(imageName);
-
-                try {
-                    response.setContentLength(imageData.length);
-
-                    ServletOutputStream ouputStream = response.getOutputStream();
-                    ouputStream.write(imageData, 0, imageData.length);
-                    ouputStream.flush();
-                    ouputStream.close();
-                } catch (IOException ioe) {
-                    log.warn(ioe.toString());
-                }
-            }
-        } else {
-            //construct the data source for the report
-            OgnlValueStack stack = ServletActionContext.getContext().getValueStack();
-            String dataSource = "" + request.getAttribute("dataSource");
-            OgnlValueStackDataSource stackDataSource = new OgnlValueStackDataSource(stack, dataSource);
-
-            //get the output format
-            String outputFormat = "" + request.getAttribute("format");
-
-            // (Map) ActionContext.getContext().getSession().get("IMAGES_MAP");
-            if (outputFormat == null) {
-                outputFormat = FORMAT_PDF;
-            }
-
-            if (!"contype".equals(request.getHeader("User-Agent"))) {
-                // Determine the directory that the report file is in and set the reportDirectory parameter
-                String systemId = getServletContext().getRealPath(request.getServletPath());
-                Map parameters = new OgnlValueStackShadowMap(stack);
-                File directory = new File(systemId.substring(0, systemId.lastIndexOf(File.separator)));
-                parameters.put("reportDirectory", directory);
-
-                byte[] output = null;
-                JasperPrint jasperPrint = null;
-
-                // Fill the report and produce a print object
-                try {
-                    JasperReport jasperReport = JasperManager.loadReport(systemId);
-                    jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, stackDataSource);
-                } catch (JRException e) {
-                    log.error("Error building report for uri " + systemId, e);
-                    throw new ServletException(e.getMessage(), e);
-                }
-
-                // Export the print object to the desired output format
-                try {
-                    if (outputFormat.equals(FORMAT_PDF)) {
-                        response.setContentType("application/pdf");
-
-                        // response.setHeader("Content-disposition", "inline; filename=report.pdf");
-                        output = JasperExportManager.exportReportToPdf(jasperPrint);
-                    } else {
-                        JRExporter exporter = null;
-
-                        if (outputFormat.equals(FORMAT_CSV)) {
-                            response.setContentType("text/plain");
-                            exporter = new JRCsvExporter();
-                        } else if (outputFormat.equals(FORMAT_HTML)) {
-                            response.setContentType("text/html");
-
-                            Map imagesMap = new HashMap();
-
-                            request.getSession().setAttribute("IMAGES_MAP", imagesMap);
-                            exporter = new JRHtmlExporter();
-                            exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap);
-                            exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "*.jasper?image=");
-                        } else if (outputFormat.equals(FORMAT_XLS)) {
-                            response.setContentType("application/vnd.ms-excel");
-                            exporter = new JRXlsExporter();
-                        } else if (outputFormat.equals(FORMAT_XML)) {
-                            response.setContentType("text/xml");
-                            exporter = new JRXmlExporter();
-                        } else {
-                            throw new ServletException("Unknown report format: " + outputFormat);
-                        }
-
-                        output = exportReportToBytes(jasperPrint, exporter);
-                    }
-                } catch (JRException e) {
-                    String message = "Error producing " + outputFormat + " report for uri " + systemId;
-                    log.error(message, e);
-                    throw new ServletException(e.getMessage(), e);
-                }
-
-                response.setContentLength(output.length);
-
-                ServletOutputStream ouputStream;
-
-                try {
-                    if (log.isDebugEnabled()) {
-                        //log.debug("Writing " + output.length + " bytes to output stream");
-                    }
-
-                    ouputStream = response.getOutputStream();
-                    ouputStream.write(output);
-                    ouputStream.flush();
-                    ouputStream.close();
-                } catch (IOException e) {
-                    log.error("Error writing report output", e);
-                    throw new ServletException(e.getMessage(), e);
-                }
-            } else {
-                // Code to handle "contype" request from IE
-                try {
-                    ServletOutputStream outputStream;
-                    response.setContentType("application/pdf");
-                    response.setContentLength(0);
-                    outputStream = response.getOutputStream();
-                    outputStream.close();
-                } catch (IOException e) {
-                    log.error("Error writing report output", e);
-                    throw new ServletException(e.getMessage(), e);
-                }
-            }
-        }
-    }
-
-    /**
-     * Run a Jasper report to CSV format and put the results in a byte array
-     * @param jasperPrint The Print object to render as CSV
-     * @param exporter The exporter to use to export the report
-     * @return A CSV formatted report
-     * @throws dori.jasper.engine.JRException If there is a problem running the report
-     */
-    private byte[] exportReportToBytes(JasperPrint jasperPrint, JRExporter exporter) throws JRException {
-        byte[] output;
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
-        exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
-        exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos);
-
-        exporter.exportReport();
-
-        output = baos.toByteArray();
-
-        return output;
-    }
-}

src/java/com/opensymphony/webwork/views/jasperreports/JasperReportsResult.java

+package com.opensymphony.webwork.views.jasperreports;
+
+import com.opensymphony.webwork.ServletActionContext;
+import com.opensymphony.webwork.dispatcher.WebWorkResultSupport;
+import com.opensymphony.xwork.ActionInvocation;
+import com.opensymphony.xwork.util.OgnlValueStack;
+import dori.jasper.engine.*;
+import dori.jasper.engine.export.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ */
+public class JasperReportsResult extends WebWorkResultSupport implements JasperReportConstants {
+    private final static Log LOG = LogFactory.getLog(JasperReportsResult.class);
+
+    private String dataSource;
+    private String format;
+
+    protected String IMAGES_URI = "/images/";
+
+    protected void doExecute(String finalLocation, ActionInvocation invocation) throws Exception {
+        if (format == null) {
+            format = FORMAT_PDF;
+        }
+
+        if (dataSource == null) {
+            String message = "No dataSource specified...";
+            LOG.error(message);
+            throw new RuntimeException(message);
+        }
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Creating JasperReport for dataSource = " + dataSource + ", format = " + format);
+        }
+
+        HttpServletRequest request = (HttpServletRequest) invocation.getInvocationContext().get(ServletActionContext.HTTP_REQUEST);
+        HttpServletResponse response = (HttpServletResponse) invocation.getInvocationContext().get(ServletActionContext.HTTP_RESPONSE);
+
+        //construct the data source for the report
+        OgnlValueStack stack = ServletActionContext.getContext().getValueStack();
+        String dataSource = "" + request.getAttribute("dataSource");
+        OgnlValueStackDataSource stackDataSource = new OgnlValueStackDataSource(stack, dataSource);
+
+        //get the output format
+        String outputFormat = "" + request.getAttribute("format");
+
+        // (Map) ActionContext.getContext().getSession().get("IMAGES_MAP");
+        if (outputFormat == null) {
+            outputFormat = FORMAT_PDF;
+        }
+
+        if (!"contype".equals(request.getHeader("User-Agent"))) {
+            // Determine the directory that the report file is in and set the reportDirectory parameter
+            ServletContext servletContext
+                    = ((ServletConfig) invocation.getInvocationContext().
+                    get(ServletActionContext.SERVLET_CONFIG)).getServletContext();
+            String systemId = servletContext.getRealPath(finalLocation);
+            Map parameters = new OgnlValueStackShadowMap(stack);
+            File directory = new File(systemId.substring(0, systemId.lastIndexOf(File.separator)));
+            parameters.put("reportDirectory", directory);
+
+            byte[] output = null;
+            JasperPrint jasperPrint = null;
+
+            // Fill the report and produce a print object
+            try {
+                JasperReport jasperReport = JasperManager.loadReport(systemId);
+                jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, stackDataSource);
+            } catch (JRException e) {
+                LOG.error("Error building report for uri " + systemId, e);
+                throw new ServletException(e.getMessage(), e);
+            }
+
+            // Export the print object to the desired output format
+            try {
+                if (outputFormat.equals(FORMAT_PDF)) {
+                    response.setContentType("application/pdf");
+
+                    // response.setHeader("Content-disposition", "inline; filename=report.pdf");
+                    output = JasperExportManager.exportReportToPdf(jasperPrint);
+                } else {
+                    JRExporter exporter = null;
+
+                    if (outputFormat.equals(FORMAT_CSV)) {
+                        response.setContentType("text/plain");
+                        exporter = new JRCsvExporter();
+                    } else if (outputFormat.equals(FORMAT_HTML)) {
+                        response.setContentType("text/html");
+
+                        Map imagesMap = new HashMap();
+
+                        request.getSession().setAttribute("IMAGES_MAP", imagesMap);
+                        exporter = new JRHtmlExporter();
+                        exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap);
+                        exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, IMAGES_URI);
+                    } else if (outputFormat.equals(FORMAT_XLS)) {
+                        response.setContentType("application/vnd.ms-excel");
+                        exporter = new JRXlsExporter();
+                    } else if (outputFormat.equals(FORMAT_XML)) {
+                        response.setContentType("text/xml");
+                        exporter = new JRXmlExporter();
+                    } else {
+                        throw new ServletException("Unknown report format: " + outputFormat);
+                    }
+
+                    output = exportReportToBytes(jasperPrint, exporter);
+                }
+            } catch (JRException e) {
+                String message = "Error producing " + outputFormat + " report for uri " + systemId;
+                LOG.error(message, e);
+                throw new ServletException(e.getMessage(), e);
+            }
+
+            response.setContentLength(output.length);
+
+            ServletOutputStream ouputStream;
+
+            try {
+                ouputStream = response.getOutputStream();
+                ouputStream.write(output);
+                ouputStream.flush();
+                ouputStream.close();
+            } catch (IOException e) {
+                LOG.error("Error writing report output", e);
+                throw new ServletException(e.getMessage(), e);
+            }
+        } else {
+            // Code to handle "contype" request from IE
+            try {
+                ServletOutputStream outputStream;
+                response.setContentType("application/pdf");
+                response.setContentLength(0);
+                outputStream = response.getOutputStream();
+                outputStream.close();
+            } catch (IOException e) {
+                LOG.error("Error writing report output", e);
+                throw new ServletException(e.getMessage(), e);
+            }
+        }
+    }
+
+    /**
+     * Run a Jasper report to CSV format and put the results in a byte array
+     *
+     * @param jasperPrint The Print object to render as CSV
+     * @param exporter    The exporter to use to export the report
+     * @return A CSV formatted report
+     * @throws dori.jasper.engine.JRException If there is a problem running the report
+     */
+    private byte[] exportReportToBytes(JasperPrint jasperPrint, JRExporter exporter) throws JRException {
+        byte[] output;
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+        exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
+        exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos);
+
+        exporter.exportReport();
+
+        output = baos.toByteArray();
+
+        return output;
+    }
+
+    public void setDataSource(String dataSource) {
+        this.dataSource = dataSource;
+    }
+
+    public void setFormat(String format) {
+        this.format = format;
+    }
+}
+

src/java/com/opensymphony/webwork/views/jsp/BeanTag.java

     }
 
     public void addParameter(String key, Object value) {
-        OgnlUtil.setProperty(findString(key), value, bean, getStack().getContext());
+        OgnlUtil.setProperty(key, value, bean, getStack().getContext());
     }
 
     public int doEndTag() throws JspException {

src/java/webwork-default.xml

             <result-type name="velocity" class="com.opensymphony.webwork.dispatcher.VelocityResult"/>
             <result-type name="chain" class="com.opensymphony.xwork.ActionChainResult"/>
             <result-type name="xslt" class="com.opensymphony.webwork.views.xslt.XSLTResult"/>
+            <result-type name="jasper" class="com.opensymphony.webwork.views.jasperreports.JasperReportsResult"/>
         </result-types>
 
         <interceptors>

src/webapp/WEB-INF/web.xml

     </servlet>
 
     <servlet>
-        <servlet-name>velocity</servlet-name>
-        <servlet-class>com.opensymphony.webwork.views.velocity.WebWorkVelocityServlet</servlet-class>
-        <load-on-startup>1</load-on-startup>
-    </servlet>
-
-    <servlet>
-        <servlet-name>jasperreports</servlet-name>
-        <servlet-class>com.opensymphony.webwork.views.jasperreports.JasperReportViewServlet</servlet-class>
-        <load-on-startup>1</load-on-startup>
-    </servlet>
-    
-    <servlet>
         <servlet-name>freemarker</servlet-name>
         <servlet-class>com.opensymphony.webwork.views.freemarker.FreemarkerServlet</servlet-class>
 
         <url-pattern>*.ftl</url-pattern>
     </servlet-mapping>
 
-   <servlet-mapping>
-        <servlet-name>jasperreports</servlet-name>
-        <url-pattern>*.jasper</url-pattern>
-    </servlet-mapping>
-
-    <servlet-mapping>
-        <servlet-name>velocity</servlet-name>
-        <url-pattern>*.vm</url-pattern>
-    </servlet-mapping>
-
     <servlet-mapping>
         <servlet-name>webwork</servlet-name>
         <url-pattern>*.action</url-pattern>

src/webapp/tags.vm

 #tag( Password "label='password test'" "name=passwordField" "value=scalar" "size=50" )
 #tag( Checkbox "label='checkbox test'" "name=checkboxField" )
 #tag( CheckboxList "label='checkboxlist test'" "name=radioField" "value=list[1].value" "list=list" "listKey=key" "listValue=value" )
-#tag( Component "label='component test'" "name=componentField" "template=/template/xhtml/empty.vm" )
+#tag( Component "label='component test'" "name=componentField" "template='empty.vm'" )
 #tag( Radio "label='radio test'" "name=radioField" "value=list[1].value" "list=list" "listKey=key" "listValue=value" )
 #tag( Select "label='multiple select test'" "name=select1" "value=multiValues" "list=multiList" "multiple=true" "size=5" )
 #tag( Select "label='select test'" "name=select2" "value=list[1].value" "list=list" "listKey=key" "listValue=value" "size=5" )