Thanks for your offer to help Martin! Listed below is the struts.xml, web.xml, and source for the Action class (taken straight from the docs). I'm testing it by simply typing the URL into the browser:
http://localhost:8000/viewer-commons-2.0/chart/ViewModeration.action I notice that if I embed the same URL into the src attribute of an img element in an html page, the chart displays. Makes me think perhaps the mime type is not being set. Is this possible? In that case would I potentially get different behavior from Apache/Tomcat on different platforms (Mac vs Linux)? --john === struts.xml === <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name="struts.devMode" value="true" /> <constant name="struts.enable.DynamicMethodInvocation" value="false" /> <package name="viewer-commons" extends="struts-default"> <global-results> <result name="sessionTimeout">sessionTimeout.jsp</result> <result name="unknownError">error.jsp</result> <result name="sessionTimeout" type="httpheader"> <param name="status">204</param> <param name="headers.exception">SessionTimeoutException</param> <param name="headers.class">${exception}</param> </result> </global-results> <global-exception-mappings> <exception-mapping exception="SessionTimeoutException" result="sessionTimeout"> </exception-mapping> <exception-mapping exception="java.lang.Exception" result="unknownError"> </exception-mapping> </global-exception-mappings> <action name="InitMapSession" class="gov.noaa.eds.arcims.tng.action.InitMapSessionAction" /> <action name="ListMapSessions" class="gov.noaa.eds.arcims.tng.action.ListMapSessionsAction"> <result>listMapSessions.jsp</result> </action> </package> <package name="chart" extends="jfreechart-default" namespace="/chart"> <action name="ServerIronLoad" class="gov.noaa.eds.arcims.tng.action.ServerIronLoadChartAction"> <result name="success" type="chart"> <param name="width">400</param> <param name="height">300</param> </result> </action> <action name="ViewModeration" class="com.jccartwright.ViewModerationChartAction"> <result name="success" type="chart"> <param name="width">400</param> <param name="height">300</param> </result> </action> </package> </struts> === ViewModerationChartAction.java === /* * example taken from Struts docs * (http://struts.apache.org/2.0.11/docs/jfreechart-plugin.html) */ package com.jccartwright; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.CategoryLabelPositions; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.renderer.category.BarRenderer; import org.jfree.data.category.CategoryDataset; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.ui.ApplicationFrame; import org.jfree.ui.RefineryUtilities; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; import org.jfree.chart.renderer.xy.StandardXYItemRenderer; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.plot.XYPlot; import com.opensymphony.xwork2.Action; import com.opensymphony.xwork2.ActionSupport; import com.opensymphony.xwork2.ModelDriven; import com.opensymphony.xwork2.Preparable; import org.apache.commons.lang.math.RandomUtils; public class ViewModerationChartAction extends ActionSupport { private JFreeChart chart; public String execute() throws Exception { // chart creation logic... XYSeries dataSeries = new XYSeries(new Integer(1)); //pass a key for this serie for (int i = 0; i <= 100; i++) { dataSeries.add(i, RandomUtils.nextInt()); } XYSeriesCollection xyDataset = new XYSeriesCollection(dataSeries); ValueAxis xAxis = new NumberAxis("Raw Marks"); ValueAxis yAxis = new NumberAxis("Moderated Marks"); // set my chart variable chart = new JFreeChart( "Moderation Function", JFreeChart.DEFAULT_TITLE_FONT, new XYPlot( xyDataset, xAxis, yAxis, new StandardXYItemRenderer(StandardXYItemRenderer.LINES)), false); chart.setBackgroundPaint(java.awt.Color.white); return super.SUCCESS; } public JFreeChart getChart() { return chart; } } === web.xml === <?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xs d" version="2.4"> <description>viewer-commons</description> <display-name>viewer-commons</display-name> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <welcome-file-list> <welcome-file>/index.jsp</welcome-file> </welcome-file-list> <listener> <listener-class>gov.noaa.eds.arcims.tng.listeners.ContextListener</listener-class> </listener> <listener> <listener-class>gov.noaa.eds.arcims.tng.listeners.SessionListener</listener-class> </listener> </web-app> ----- Original Message ----- From: Martin Gainty <[EMAIL PROTECTED]> Date: Saturday, January 5, 2008 2:56 pm Subject: RE: S2: chart result type not recognized > > Johncan you post the code you are implementingjspsActionServlet > as well as the configuration filesweb.xmlany struts*.xml > Thanks/Martin > ______________________________________________Disclaimer and > confidentiality noteEverything in this e-mail and any attachments > relates to the official business of Sender. This transmission is of > a confidential nature and Sender does not endorse distribution to > any party other than intended recipient. Sender does not > necessarily endorse content contained within this transmission.> > Date: Sat, 5 Jan 2008 11:30:45 -0700> From: > [EMAIL PROTECTED]> Subject: Re: S2: chart result type not > recognized> To: user@struts.apache.org> > Hi Ian,> > thanks for > your reply. For testing purposes, I'm simply calling it via URL:> > > http://localhost:8080/viewer-commons- > 2.0/chart/serverIronLoadChart.action> > Strangely, I was able to > get the chart example from the docs to run in> new context, I just > can't seem to be able to integrate it into a more> complex existing > application. I'm assuming that the result type is not> being > recognized, but don't see any errors in the logs and don't know> > how to pursue debugging the problem.> > By the way, I really > enjoyed your recent Struts2 book!> > > --john> > ----- Original > Message -----> From: Ian Roughley <[EMAIL PROTECTED]>> Date: Friday, > January 4, 2008 7:43 am> Subject: Re: S2: chart result type not > recognized> > > How are you referencing the action? I always use an > img tag like > > this:> > <img src="serverIronLoadChart.action" />> > > > > /Ian> > > > -- > > Ian Roughley> > From Down & Around, Inc.> > > Consulting * Training / Mentoring * Agile Process * Open Source> > > web: http://www.fdar.com - email: [EMAIL PROTECTED]> > > > > > > > > John Cartwright wrote:> > > Hello All,> > >> > > I'm having a > little trouble getting a chart result type > > configured > > > > using the package declaration below. Whenever I hit the > > > associated > > > URL, my browser prompts me to save a "bin" file > rather than > > > displaying the chart. The bin file is a valid > png, but somehow > > Struts > > > is not recognizing the returned > type. Can anyone suggest what > > I'm > > > doing wrong?> > >> > > > Thanks!> > >> > > -- john> > >> > >> > > <package name="chart" > extends="jfreechart-default" > > namespace="/chart">> <action > name="serverIronLoadChart"> > > > > > class="gov.noaa.eds.arcims.tng.action.ServerIronLoadChartAction">> > > <result type="chart">> > > <param name="width">400</param>> > > <param name="height">300</param>> > > </result>> > > > > > </package>> > >> > > ------------------------------------------------------------------> > ---> > > To unsubscribe, e-mail: [EMAIL PROTECTED]> > > For additional commands, e-mail: [EMAIL PROTECTED]> > >> > > > --------------------------------------------------------------------> > -> > To unsubscribe, e-mail: [EMAIL PROTECTED]> > For additional commands, e-mail: [EMAIL PROTECTED]> > > > > > ---------------------------------------------------------------------> To unsubscribe, e-mail: [EMAIL PROTECTED]> For additional commands, e-mail: [EMAIL PROTECTED]> > _________________________________________________________________ > Make distant family not so distant with Windows Vista® + Windows > Live™.http://www.microsoft.com/windows/digitallife/keepintouch.mspx?ocid=TXT_TAGLM_CPC_VideoChat_distantfamily_012008 --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]