import java.sql.*; import java.lang.*; import*; import javax.servlet.*; import javax.servlet.http.*; public class VbarDataServlet 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 = "\n"+ "data1series1: 34000\n"+ "data2series1: 34900\n"+ "data3series1: 52000\n"+ "data4series1: 27600\n"+ "data1series2: 14000\n"+ "data2series2: 14900\n"+ "data3series2: 12000\n"+ "data4series2: 16600\n"+ "data2series3: 34100\n"+ "data3series3: 52900\n"+ "data4series3: 56650\n"; return(rsltStr); } //----------------------------------------------------------------------------- } // End class