Hints for Assignment #8
Initial Screen
Hints for the initial page You need a DOCTYPE with the proper namespaces defined You need to import the facebook api You need to create the XMLHttpRequest object as shown in class You need to set up the call to your Java servlet, e.g. req.open("GET", " true); You need to set up the routine that gets called when the servlet returns data, e.g. req.onreadystatechange = processReqChange; The servlet returns JSON data; you need to evaluate the string and then build a table with three rows of stock results; remember to include a last column of radio buttons Then create a button, e.g. BUTTON.innerHTML += " "; When the button is clicked call the Facebook routine to create the prompt and login to Facebook, e.g. FB.ui( { method: ‘stream.publish’, message: ‘Current stock quote’, AND OTHER ARGUMENTS )
Outline of the Java Servlet Various java library imports public class MyServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); String feedURLString = request.getParameter("feedURL"); String script =""; initialize JSON objects try { StringTokenizer st = new StringTokenizer(feedURLString); while (st.hasMoreTokens()) { read the three stock symbols } Call you modified Perl script from assignment #6 which creates an XML output file URL url = new URL(" Read the XML output file created by the Perl Script Convert the XML output into JSON output Return the result to your web page where a JavaScript function processes the JSON