Appendix A: Web Server Application

 

Using a Servlet

A JMSL chart can be returned as an image from a Web server using a servlet. The mechanism depends on the version of the Java runtime library being used.

Images are rendered using the standard Java class javax.imageio.ImageIO. This class can be used on a headless server—that is, a server running without graphical interfaces. While most desktop Unix systems run the X Windows System, Unix servers are often run without it. Java runs in a headless mode if the system property java.awt.headless is set to true.

Java Server Pages (JSP) and servlets are the standard mechanism for adding Java functionality to Web servers.

Adding charts to a Web page is complicated by the fact that in response to a request a Web server can return either a text HTML page or a bitmap image. The response to the initial request is an HTML page that contains an image tag. When the browser parses the HTML page and finds the image tag, it makes a second request to the Web server. The Web server then returns the bitmap image in response to this second request.

The JMSL classes JspBean and ChartServlet are used to coordinate this process. During the first request, one or more JMSL chart trees are constructed and stored in the HttpSession object, obtained from the HttpServletRequest object, using the method JspBean.registerChart. The method Jsp.getImageTag is used to construct an HTML image tag with an identifier for the chart in the session object. This image tag refers to the servlet ChartServlet. The second browser request is therefore directed to the ChartServlet, which uses the identifier to retrieve the chart from the session object.

The use of the session object to hold the chart requires that the user's browser allow cookies, used to track sessions across requests.

More:

Generating a Chart with a JSP

Generating Charts with Client-side Imagemaps

Servlet Deployment



Visual Numerics - Developers of IMSL and PV-WAVE
http://www.vni.com/
PHONE: 713.784.3131
FAX:713.781.9260