Applet - Servlet Combination
One of
the factors to consider when deciding between implementing
the applet or servlet form of the graph is that, browsers
in general do not print applets very well and the results
can vary between browser makes and versions. The servlet however
returns the graph image to the browser in PNG format and as
such will print consistently without any problems across all
browser makes and versions.
Another
factor to consider when deciding to implement the applet or
servlet is whether the interactive features of the applet
are required (mouseover pop-ups and mouseclick URL functionality).
In the servlet form, the graph is returned to the browser
as a PNG image and as such the interactive features of the
applet are not available.
This example
demonstrates how to implement the applet and servlet together
so that all the interactive features of the applet are presented
to the user and also giving the user the option of printing
the page containing the graph.
On this
page we implement the servlet ( which acquires both the configuration
and graph data from data files). This page is almost identical
and contains the servlet implementation which is universally
printable.
The configuration
data is acquired from the text file pieprops.txt
(click here to view)
and the graph data is acquired from the text file piedata.txt
(click here to view).
and here
is the HTML code,
<img src="http://localhost:8080/servlet/PiechartServlet?
config=http://www.jpowered.com/pie_chart/Examples/pieprops.txt&
data=http://www.jpowered.com/pie_chart/Examples/piedata.txt"
width="550" height="450">
For a
full explanation of and range of values for the above parameters
please see the Documentation.
Note:
If you are using the evaluation version then in the applet
a pop-up window will appear upon the startup and an evaluation
message will be incorporated by the servlet. Both these features
have been removed from the licensed version. Licensing information
can be found at http://www.jpowered.com/graph_chart/index.htm
<< back to Examples Index
<< back to Getting
Started
|