Hints for Assignment #8. Initial Screen Hints for the initial page You need a DOCTYPE with the...
-
Upload
abraham-dickerson -
Category
Documents
-
view
212 -
download
0
Transcript of Hints for Assignment #8. Initial Screen Hints for the initial page You need a DOCTYPE with the...
![Page 1: 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.](https://reader036.fdocuments.in/reader036/viewer/2022083009/5697bf9b1a28abf838c92b4c/html5/thumbnails/1.jpg)
Hints for Assignment #8
![Page 2: 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.](https://reader036.fdocuments.in/reader036/viewer/2022083009/5697bf9b1a28abf838c92b4c/html5/thumbnails/2.jpg)
Initial Screen
![Page 3: 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.](https://reader036.fdocuments.in/reader036/viewer/2022083009/5697bf9b1a28abf838c92b4c/html5/thumbnails/3.jpg)
Hints for the initial page• You need a DOCTYPE with the proper namespaces defined• <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"
xmlns:fb="http://www.facebook.com/2008/fbml">
• You need to import the facebook api• <script src="http://connect.facebook.net/en_US/all.js"></script>
• 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", "http://csci571.usc.edu:PORTNO/examples/servlet/MyServlet?args",
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 += "<input type='button' name='btn' id='b' value='Post to Facebook News Feed'
onClick='streamPublish()' disabled='disabled' />";• 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 )
![Page 4: 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.](https://reader036.fdocuments.in/reader036/viewer/2022083009/5697bf9b1a28abf838c92b4c/html5/thumbnails/4.jpg)
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("http://cs-server.usc.edu:37547/cgi-bin/account.pl");• 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