Servlets.com

Home

What's New?

com.oreilly.servlet

Servlet Polls

Mailing Lists

Servlet Engines

Servlet ISPs

Servlet Tools

Documentation

Online Articles

The Soapbox

"Java Servlet
Programming,
Second Edition"

"Java Enterprise
Best Practices"

Speaking & Slides

About Jason

XQuery Affiliate

Advertising Info

The Book
Chapter 5 Examples from Java Servlet Programming

  • 5-2: A servlet using persistent connections
  • 5-3: Hello, htmlKona
  • 5-4: Weather forecast constructed by hand
  • 5-5: Weather forecast using HTML generation
  • 5-6: Weather forecast using HTML generation creatively
  • 5-7: Random redirector
  • 5-8: The current time, kept current
  • 5-9: An explained host change

Examples from other chapters:


Example 5.2: A servlet using persistent connections
This servlet enables persistent connections (keep-alive) using a ByteArrayOutputStream to buffer its output.

Example 5.3: Hello, htmlKona
This servlet shows the ubiquitous HelloWorld servlet, rewritten to take advantage of WebLogic's htmlKona package.
    • Try it (disabled, no htmlKona license)
    • Source

Example 5.4: Weather forecast constructed by hand
This servlet shows a servlet that creates a weather forecast page without using HTML generation, manually sending its content wrapped with almost a hundred HTML tags.

Example 5.5: Weather forecast using HTML generation
This servlet is Example 5.4 rewritten to use HTML generation.
    • Try it (disabled, no htmlKona license)
    • Source

Example 5.6: Weather forecast using HTML generation creatively
This servlet is Example 5.5 rewritten to use HTML generation creatively by reusing objects and subclassing.
    • Try it (disabled, no htmlKona license)
    • Source

Example 5.7: Random redirector
This servlet performs a random redirect, sending a client to a random site selected from its site list. Depending on the site list, a servlet like this could have many uses. As it stands now, it's just a jump-off point to a selectino of cool servlet sites. With a site list containing advertising images, it can be used to select the next ad banner.

Example 5.8: The current time, kept current
This servlet shows a servlet that uses client pull to display the current time, updated every 10 seconds.

Example 5.9: An explained host change
This servlet redirects requests for one host to another host, giving an exmplanation to the client before the redirection.

 


Home   com.oreilly.servlet   Polls   Lists   
Engines   ISPs   Tools   Docs   Articles   Soapbox   Book

Copyright © 1999-2005 Jason Hunter
Privacy Policy

webmaster@servlets.com
Last updated: March 1, 2009