Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
450
Chapter 17 Using Applets As Servlet Front Ends
Listing 17.6 QueryGenerator.java (continued)
  // The real, honest to goodness queries people have sent : )
  
  private String randomQuery() {
    String[] locations = { "Where ", "How " };
    String[] actions =
      { "can I look for ", "can I find ", "can I get " };
    String[] sources =
      { "information ", "resources ", "data ", "references " };
    String[] prepositions = { "on ", "about ", "concerning " };
    String[] subjects =
      { "the book Core Servlets and JavaServer Pages",
        "the text Core Servlets and JavaServer Pages",
        "Core Servlets and JavaServer Pages",
        "Core Servlets and JSP",
        "the book Core Web Programming (Java 2 Edition)",
        "Core Web Programming (Java 2 Edition)",
        "servlet programming", "JavaServer Pages", "JSP",
        "Java alternatives to CGI", "server side Java" };
    String[] endings = { "?", "?", "?", "?!", "?!!!?" };
    String[][] sentenceTemplates =
      { locations, actions, sources,
        prepositions, subjects, endings };
    String query = "";
    for(int i=0; i
      query = query + randomEntry(sentenceTemplates[i]);
    }
    return(query);
  }
  private String randomEntry(String[] strings) {
    int index = (int)(Math.random()*strings.length);
    return(strings[index]);
  }
}
17.5 Sending Data by POST and 
Processing the Results Directly
(HTTP Tunneling)
With 
GET
 data, an applet has two options for the results of a submission: tell
the browser to display the results (construct a 
URL
 object and call 
getAp 
pletContext().showDocument
) or process the results itself (construct a
URL
 object, get a 
URLConnection
, open an input stream, and read the
Home page for this book: www.coreservlets.com; Home page for sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

jsp web hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Jsp Web Hosting Cheapest Web Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved