20-Servers-and-Applets

20-Servers-and-Applets - 2006 Marty Hall Using Applets as...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
2 J2EE Training: http://courses.coreservlets.com/ Servlets, JSP, Struts, JSF, Hibernate, AJAX, Java 5, etc. Developed and taught by well-known author and developer. At public venues or onsite at your location. © 2006 Marty Hall Using Applets as Front Ends to Server-Side Programs 3 Developed and taught by well-known author and developer. At public venues or onsite at your location. © 2006 Marty Hall For live Java training, please see training courses at http://courses.coreservlets.com/. Servlets, JSP, Struts, JSF, AJAX, Java 5, etc. Taught by the author of Core Servlets and JSP , More Servlets and JSP , and this tutorial. Available at public venues, or customized versions can be held on-site at your organization.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 J2EE training: http://courses.coreservlets.com Agenda Sending GET data and having the browser display the results Sending GET data and processing the results within the applet (HTTP tunneling) Using object serialization to exchange high- level data structures between applets and servlets Sending POST data and processing the results within the applet (HTTP tunneling) Bypassing the HTTP server altogether 5 J2EE training: http://courses.coreservlets.com Sending GET Request and Displaying Resultant Page Applet requests that browser display page – showDocument try { URL programURL = new URL(baseURL + "?" + someData); getAppletContext().showDocument(programURL); } catch(MalformedURLException mue) { . .. }; URL-encode the form data String someData = name1 + " = " + URLEncoder.encode(val1) + " & " + name2 + "=" + URLEncoder.encode(val2) + "&" + ... nameN + "=" + URLEncoder.encode(valN);
Background image of page 2
6 J2EE training: http://courses.coreservlets.com GET Request Example: Applet public class SearchApplet extends Applet implements ActionListener { ... public void actionPerformed(ActionEvent event) { String query = URLEncoder.encode(queryField.getText()); SearchSpec[] commonSpecs = SearchSpec.getCommonSpecs(); for(int i=0; i<commonSpecs.length-1; i++) { try { SearchSpec spec = commonSpecs[i]; URL searchURL = new URL(spec.makeURL(query, "10")); String frameName = "results" + i; getAppletContext().showDocument(searchURL, frameName); } catch(MalformedURLException mue) {} } } } 7 J2EE training: http://courses.coreservlets.com
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 11

20-Servers-and-Applets - 2006 Marty Hall Using Applets as...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online