import java.sql.*; import java.lang.*; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class AreaDataServlet extends HttpServlet { // // This simple servlet is designed to demonstrate how a servlet can be used // to return data to either the graphing applet or servlet. // As you will see the main routine ( doGet() ) uses the method // GraphData() to construct the return data. // Although in this example the GraphData() rountine simply builds the return // data from 'hard coded' values, in practice this rountine would be expanded // to first gather data from any number of datasources. // eg. databases, files other server processes. // // For further information visit, // http://www.jpowered.com/area_graph/ // //----------------------------------------------------------------------------- public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); ServletOutputStream out = res.getOutputStream(); // Return the Data out.println(GraphData()); } // End doGet //----------------------------------------------------------------------------- public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {doGet(request, response);} //----------------------------------------------------------------------------- public static String GraphData() { String rsltStr = "data1series1: 3162\n"+ "data2series1: 2516\n"+ "data3series1: 2945\n"+ "data4series1: 3980\n"+ "data5series1: 5750\n"+ "data6series1: 6230\n"+ "data7series1: 4765\n"+ "data8series1: 5636\n"+ "data9series1: 5120\n"+ "data10series1: 4365\n"+ "data11series1: 5789\n"+ "data12series1: 5623\n"+ "data1series2: 6840\n"+ "data2series2: 6704\n"+ "data3series2: 3945\n"+ "data4series2: 6780\n"+ "data5series2: 4750\n"+ "data6series2: 2230\n"+ "data7series2: 1065\n"+ "data8series2: 636\n"+ "data9series2: 520\n"+ "data10series2: 250\n"+ "data4series3: 253\n"+ "data5series3: 682\n"+ "data6series3: 989\n"+ "data7series3: 1920\n"+ "data8series3: 1240\n"+ "data9series3: 2240\n"+ "data10series3: 1450\n"+ "data11series3: 2808\n"+ "data12series3: 2050\n"; return(rsltStr); } //----------------------------------------------------------------------------- } // End class