ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  how to install it in a web application of SSH ?
Posted by liwenhaosuper on Apr-06-2011 23:24
Hi, as usual, I would like to ask you how to install it in a web application of SSH.

I copy the .jar file to my application path of   "WebRoot\\WEB-INF\\lib" and add the following codes to the web.xml:
<servlet>
<servlet-name>GetSessionImage</servlet-name>
<servlet-class>ChartDirector.GetSessionImage</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>GetSessionImage</servlet-name>
<url-pattern>*.chart</url-pattern>
</servlet-mapping>



and I copy code to my .jsp file.But it doesnot show the chart:


<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@page import="ChartDirector.*" %>
<%
// The data for the bar chart
double[] data = {85, 156, 179.5, 211, 123};

// The labels for the bar chart
String[] labels = {"Mon", "Tue", "Wed", "Thu", "Fri"};

// Create a XYChart object of size 250 x 250 pixels
XYChart c = new XYChart(250, 250);

// Set the plotarea at (30, 20) and of size 200 x 200 pixels
c.setPlotArea(30, 20, 200, 200);

// Add a bar chart layer using the given data
c.addBarLayer(data);

// Set the labels on the x axis.
c.xAxis().setLabels(labels);

// Output the chart
String chart1URL = c.makeSession(request, "chart1");

// Include tool tip for the chart
String imageMap1 = c.getHTMLImageMap("", "", "title='{xLabel}: US${value}K'");
%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">

    <title>My JSP 'input.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

  </head>

  <body><!--
    <form action="test.do" method="post">
    <input type="text" name="str1">
    <input type="text" name="str2">
    <input type="submit">
    --></form>
    <div style="font-size:18pt; font-family:verdana; font-weight:bold">
                     Simple Bar Chart
    </div>
    <hr color="#000080">
    <div style="font-size:9pt; font-family:verdana; margin-bottom:1.5em">
    <a href="viewsource.jsp?file=<%=request.getServletPath()%>">View Source Code</a>
    </div>
    <img src='<%=response.encodeURL("getchart.jsp?"+chart1URL)%>'
       usemap="#map1" border="0">
    <map name="map1"><%=imageMap1%></map>
  </body>
</html>


It compiles fine , but no chart!

I would like to get you advice. Thank you.

  Re: how to install it in a web application of SSH ?
Posted by Peter Kwan on Apr-07-2011 02:05
Hi liwenhaosuper,

Note that the code needs "getchart.jsp". Have you copied "getchart.jsp" to the same directory as your JSP file?

To diagnose the problem, please use the original "Simple Bar Chart" sample code. Do not add anything (such as basePath, etc). Please check if you can see the bar chart. If you can see the bar chart with the original sample code, but not with your modified code, it means the issue may be related to the code you have added.

If even the original unmodified sample code does not work, please inform me what is the error message. If you see no error message, but a broken image symbol (a "red X"), please inform me what is the error message inside the "red X". See:

http://www.chartdir.com/forum/download_thread.php?site=chartdir&bn=chartdir_faq&thread=1117817200

Please kindly let me know what is the result.

Regards
Peter Kwan