Sign in to follow this  
gremsi26

Exporting And Saving Charts On The Server In Jsp

Recommended Posts

I have followed the instructions from here http://docs.fusionch...ServerSave.html

 

However when it tries to access the servlet right after it has captured the data I get this error:

SEVERE: Servlet.service() for servlet [FCExporter] in context with path [/j2ee] threw exception
java.lang.IllegalStateException: getOutputStream() has already been called for this response
at org.apache.catalina.connector.Response.getWriter(Response.java:636)
at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:214)
at com.fusioncharts.exporter.resources.FCExporter_IMG.exportOutput(FCExporter_IMG.java:259)
at com.fusioncharts.exporter.servlet.FCExporter.doPost(FCExporter.java:212)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

 

I have included the contents of my jsp file below:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<%@ taglib uri="http://www.fusioncharts.com/jsp/core" prefix="fc"%>  
<html> 
<head> 
<title>Creating a chart in Java from an array</title> 
<script type="text/javascript" src="Charts/FusionCharts.js"></script> 
	<script type="text/javascript">
  		//Callback handler method which is invoked after the chart has saved image on server.
  		function FC_Exported(objRtn){              
             if (objRtn.statusCode=="1"){
        		alert("The chart was successfully saved on server. The file can be accessed from " + objRtn.fileName);
             }else{
        		alert("The chart could not be saved on server. There was an error. Description : " + objRtn.statusMessage);
             }
  		}
     </script>
</head>
<body> 

<%   
String xmlData = "<chart animation='0' exportEnabled='1' exportCallback='FC_Exported' exportHandler='FCExporter' exportAtClient='0' exportAction='download' caption='Weekly Sales Summary' xAxisName='Weeks' yAxisName='Amount' numberPrefix='><set label='Week 1' value='14400' /> <set label='Week 2' value='19600' /><set label='Week 3' value='24000' /> <set label='Week 4' value='15700' /></chart>";
%> 

<script type="text/javascript">

function FC_Rendered ( DOMId )
{
		if ( FusionCharts(DOMId).exportChart )
		{
		//	// you can change the value of exportFormat to 'PNG' or 'PDF'
			q=FusionCharts(DOMId).exportChart( { "exportFormat" : 'JPG' } );
		}
}

</script>

<c:set var="strXML" value="<%=xmlData%>" /> 
<fc:render chartId="chart_from_array" swfFilename="Charts/Column3D.swf" width="640" height="400" debugMode="false" registerWithJS="true" xmlData="${strXML}" /> 
</body> 
</html>

 

 

Any suggestions on how this can be fixed? Thanks!

Edited by gremsi26

Share this post


Link to post
Share on other sites
Guest Bindhu

Hi,

 

Welcome to the FusionCharts Forum :)

 

Thank you for the post.

 

I am afraid, we are unable to replicate the issue.

 

Can you please share the entire project, not just the JSP, to replicate the issue.

 

Also, please let us know the environment on which you are able to replicate the issue.

 

Awaiting your response.

Share this post


Link to post
Share on other sites

Hi,

 

Welcome to the FusionCharts Forum :)

 

Thank you for the post.

 

I am afraid, we are unable to replicate the issue.

 

Can you please share the entire project, not just the JSP, to replicate the issue.

 

Also, please let us know the environment on which you are able to replicate the issue.

 

Awaiting your response.

 

Hi Bindhu,

 

Sure, you will be able to download my entire project here: https://www.dropbox....m8igvf/j2ee.rar

You should be able to replicate this issue if you import the project in eclipse and add the project to Tomcat 7.0 in eclipse.

 

I think I might be setting up my servlets or paths incorrectly but I have double checked and nothing seems to be wrong.

 

Thanks for the help!

Edited by gremsi26

Share this post


Link to post
Share on other sites

Also I do have one more question about exporting javascript charts on the server. I have set up batik and index.php correctly as described here: http://docs.fusioncharts.com/charts/contents/index.html?FirstChart/UsingPureJS.html

It seems that when index.php converts the svg to image using batik it will correctly convert the image in the temp folder. However when it tries to send the image back to the browser the image seems to be the same size but it will not open. Any thoughts on this?

Share this post


Link to post
Share on other sites
Guest Bindhu

Hi,

 

I downloaded the project and I found some issue.

 

Please find attached screen shot.

 

Can you please throw some light on this?

post-23884-0-16682500-1340770270_thumb.png

Share this post


Link to post
Share on other sites

Hi,

 

I downloaded the project and I found some issue.

 

Please find attached screen shot.

 

Can you please throw some light on this?

 

That seems to be a problem with jquery.min.js. But i seem to have figured it out. I had a few problems with my implementation. The servlets were not mapped correctly and I included the batik files in the root lib folder instead of WEB-INF/lib. Thanks for taking the time to help!

 

 

Share this post


Link to post
Share on other sites
Guest Bindhu

Hi,

 

We are glad to know that you have managed to resolve your issue.

 

Happy FusionCharting :D

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this