import java.sql.*; import java.lang.*; import*; import javax.servlet.*; import javax.servlet.http.*; public class BarDataServlet 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, // // //----------------------------------------------------------------------------- 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: 5000\n"+ "data2series1: 6605\n"+ "data3series1: 3480\n"+ "data4series1: 1940\n"+ "data5series1: 2420\n"+ "data6series1: 1324\n"+ "data1series2: 8560\n"+ "data2series2: 7240\n"+ "data3series2: 3000\n"+ "data4series2: 2400\n"+ "data5series2: 1500\n"+ "data6series2: 1500\n"+ "data1series3: 3500\n"+ "data2series3: 2900\n"+ "data3series3: 3000\n"+ "data4series3: 1200\n"+ "data5series3: 4200\n"+ "data6series3: 3500\n"; return(rsltStr); } //----------------------------------------------------------------------------- } // End class