home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 March / CMCD0305.ISO / Software / Shareware / Grafica / 3dpie / Documentation / ServerTemplateScripts / PieDataServlet.java < prev   
Text File  |  2003-06-03  |  2KB  |  70 lines

  1. import java.sql.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. import javax.servlet.*;
  5. import javax.servlet.http.*;
  6.  
  7. public class PieDataServlet extends HttpServlet {
  8. //
  9. // This simple servlet is designed to demonstrate how a servlet can be used
  10. // to return data to either the graphing applet or servlet.
  11. // As you will see the main routine ( doGet() ) uses the method
  12. // GraphData() to construct the return data.
  13. // Although in this example the GraphData() rountine simply builds the return
  14. // data from 'hard coded' values, in practice this rountine would be expanded
  15. // to first gather data from any number of datasources.
  16. // eg. databases, files other server processes.
  17. //
  18. // For further information visit,
  19. // http://www.jpowered.com/pie_chart/
  20. //
  21. //-----------------------------------------------------------------------------
  22.  
  23.     public void doGet(HttpServletRequest req, HttpServletResponse res)
  24.            throws ServletException, IOException {
  25.  
  26.         res.setContentType("text/html");
  27.         ServletOutputStream out = res.getOutputStream();
  28.  
  29.         // Return the Data
  30.         out.println(GraphData());
  31.  
  32.                            } // End doGet
  33. //-----------------------------------------------------------------------------
  34.  
  35.  
  36.     public void doPost(HttpServletRequest request,HttpServletResponse response)
  37.                 throws ServletException, IOException {doGet(request, response);}
  38.  
  39. //-----------------------------------------------------------------------------
  40.  
  41.     public static String GraphData() {
  42.         String rsltStr =
  43.          "data1series1:   5000\n"+
  44.          "data2series1:   6605\n"+
  45.          "data3series1:   3480\n"+
  46.          "data4series1:   1940\n"+
  47.          "data5series1:   2420\n"+
  48.          "data6series1:   1324\n"+
  49.          "data1series2:   8560\n"+
  50.          "data2series2:   7240\n"+
  51.          "data3series2:   3000\n"+
  52.          "data4series2:   2400\n"+
  53.          "data5series2:   1500\n"+
  54.          "data6series2:   1500\n"+
  55.          "data1series3:   3500\n"+
  56.          "data2series3:   2900\n"+
  57.          "data3series3:   3000\n"+
  58.          "data4series3:   1200\n"+
  59.          "data5series3:   4200\n"+
  60.          "data6series3:   3500\n";
  61.  
  62.  
  63.          return(rsltStr);
  64.                               }
  65.  
  66. //-----------------------------------------------------------------------------
  67.  
  68.  
  69.  
  70. } // End class