To start using NetCharts Pro there are three steps to including and configuring NetCharts Pro within your web application.

  1. Include the NetCharts Pro JAR files - Include the JAR files, update classpath as needed.
  2. Configure the Resource Servlet - Made available the resource servlet to deliver various web content
  3. Include the NetCharts Pro license - Include the NetCharts Pro license file within the application.

Step 1 - Include the JAR files

The JAR files needed to include NetCharts Pro within a web application are included in the lib folder in the NetCharts Pro distribution. If you have not already downloaded NetCharts Pro click the Download NetCharts Pro above and click the “Download Now” button. Upon registering you will receive an email with download information.

The minimum set of NetCharts Pro JAR files required in an application that generates raster images such as PNG with NetCharts Pro 7.1 is:

If you would like to start producing vector images such as SVG you need to include the JAR files that start with batik*:

Follow the appropriate method to include the JAR files within your application. The web application may only require that the JAR files be placed in the WEB-INF\lib folder of the web application. Within Eclipse you may need to right-click the References Libraries folder and select the Build Path -> Configure Build Path menu to bring up the Java Build Path dialog and select Add External JARs... to locate the JAR files on disk and include within the application classpath.

Step 2 - Configure the Resource Servlet

NetCharts Pro includes a utility Servlet that must be present in an NetCharts Pro enabled web application. The Servlet is netcharts.pro.util.NFResourceServlet and it is delivered in ncp-api.jar. This Servlet is responsible for delivering a variety of content to web applications including binary image data, vector image files, javascript libraries, applet jars and license information. This Servlet can be integrated into a web application framework and configured with the following entries in the web.xml deployment descriptor.

	<servlet>
		<servlet-name>ResourceServlet</servlet-name>
		<display-name>ResourceServlet</display-name>
		<servlet-class>netcharts.pro.util.NFResourceServlet</servlet-class>
		<init-param> 
			<param-name>RetainImageInSession</param-name>
			<param-value>true</param-value>
		</init-param>	
		<load-on-startup>1</load-on-startup>
	</servlet>	
	...
	<servlet-mapping>
 		<servlet-name>ResourceServlet</servlet-name>
 		<url-pattern>/getresource</url-pattern> 
 	</servlet-mapping> 	
	<servlet-mapping>
 		<servlet-name>ResourceServlet</servlet-name>
 		<url-pattern>/NFLicense.dat</url-pattern> 
 	</servlet-mapping> 	
	<servlet-mapping>
 		<servlet-name>ResourceServlet</servlet-name>
 		<url-pattern>/netcharts.jar</url-pattern> 
 	</servlet-mapping> 	
	<servlet-mapping>
 		<servlet-name>ResourceServlet</servlet-name>
 		<url-pattern>/applets/NFLicense.dat</url-pattern> 
 	</servlet-mapping> 	
	<servlet-mapping>
 		<servlet-name>ResourceServlet</servlet-name>
 		<url-pattern>/applets/ncp-core.jar</url-pattern> 
 	</servlet-mapping>		

NFResourceServlet is responsible for delivering NetCharts Pro generated content to web pages. HTML code generated by the NetCharts Pro chart and page creation code will contain indirect references to this Servlet in order to request content. For example, an NetCharts Pro application might issue a call to create an HTML page containing a pie chart:

String page = NFServletUtil.getPage(request, chart, new NFRasterPageParams(NFRasterPageParams.MIME_TYPE_PNG));

This call results in the creation of an HTML page containing code that looks like

<img src="/getresource?image=1611207186" border="0" style="z-index:0;"/>

Given the above web.xml entries, /getresource is a reference to NFResourceServlet which, in this case, retrieves the binary PNG image data and returns it to the browser. Other HTML code created by NetCharts Pro may make similar requests to NFResourceServlet for other types of content.

NFResourceServlet supports a RetainImageInSession initialization parameter. Setting RetainImageInSession to true will ensure that once a chart image has been generated, it will be available for re-delivery in response to subsequent requests until the session times out, or until the image is explicitly deleted from the session. This is useful in the event that the user re-requests the image either by reloading the web page, or by printing the web page.

Step 3 - Include the NetCharts Pro license

NFResourceServlet is also responsible for checking that an application contains a valid NetCharts Pro license. By default, the Servlet expects the license file, NetChartsPro.license, to be located in WEB-INF/classes/NetChartsPro.license. Placing the NetChartsPro.license in the WEB-INF/classes/ folder of the application is the most common approach to include the license.

The NFResourceServlet Servlet does support initialization parameters that alter the way it locates a license. The LicenseDirectory parameter can be used to specify a directory within the web application other than WEB-INF/classes in which to search for a license. The License parameter can contain a base 64 encoded string version of the contents of NetChartsPro.license, in which case a license file does not explicitly need to be present in the web application. Note the use of these two parameters require that the Servlet be loaded at startup as shown above.