JSP
This section describes using WebCharts3D in JSP pages to produce interactive images during page processing. (See Overview for more information). Before you start producing images, you will need to setup WebCharts3D on the server as it is described in Setup section.
The following is a typical code snippet that WebCharts3D Designer produces with explanation of each step. For more information see API section of this chapter.
// Import the required classes
<%@ page import = "com.gp.api.jsp.MxServerComponent" %>
<%@ page import = "com.gp.api.jsp.MxChartDescription"%>
<%
// Obtain an instance of MxServerComponent
MxServerComponent svr = MxServerComponent.getDefaultInstance(application);
// Obtain an instance of MxChartDescription and specify desired
// attributes. You can also load styles and data from files or
// databases as it is described in the API section.
MxChartDescription myTable = svr.newImageSpec();
myTable.width = 256 ;
myTable.height= 256 ;
myTable.type = "PNG" ;
myTable.style = "<frameChart> <legend isVisible=\"false\"/> </frameChart>" ;
myTable.model = "<XML type=\"default\"> <<ROW 2001=\"100.0\">Sample 0:</ROW> </XML>";
// Write out image or plug-in tag
out.write(svr.getImageTag(myTable,"/getImage.jsp?image="));
%>
NOTE. The above code will insert an image or plugin tag pointing back to the web server's getImage.jsp file. This file will retrieve produced image and send it back to the browser. This file should exist on the server, but the precise location of this file (as well as it's name) can be changed. The above code specifies "/getImage.jsp" that means that this file should be located in the root of your application. If you change this name to "getImage.jsp", then this file should exist in the same folder where your page is located. WebCharts3D Designer's Setup panel can generate this file or you can copy it from the samples folder of the installation directory.