JRun Sample Servlets

The following examples show off some of the capabilities of servlet. These examples are also a good starting point for writing your own servlets.

Note: These samples assume this document resides somewhere in your web server's document path and that the mapping for running servlets is /servlet.

Hello World Servlet

This servlet displays the famous first line of any programmer, "Hello World".
view source

Simple Servlet

This servlet, as the name implies, is another simple example of a servlet sending some output. view source

Date Servlet

This servlet displays the current date and time local to timezone of the server running the servlet.
view source

Counter Servlet

This servlet demonstrates a servlet that uses Cookies to store the number of times a user has visited your servlet.
view source

Snoop Servlet

This servlet displays some header information from your request as well as any form data. This servlet is useful as a diagnostic tool to see what your browser is sending to your servlet.
view source

Finger Servlet

This servlet acts as a simple gateway for the finger protocol. It demonstrates how a servlet can make its own socket connection to the outside world:
view source

Username:
Hostname:

Upper Case Filter Servlet

This servlet demonstrates one of the advanced features of JRun, the ability to chain servlets together. In this example, the 'SimpleServlet' servlet from above has its output sent to the UpperCaseFilter servlet.
view source

Redirect Servlet

This servlet will redirect your browser to a specific location. It demonstrates the ability for a servlet to send redirect headers. Enter a URL in the field below and the servlet will take you there.
view source

Location:

Link Checker Servlet

This servlet checks to see that all links in a hierarchy on a local host (below the start URL) are valid. This servlet also demonstrates the use of sockets and URL connections:
view source

Full URL to start from:
Recursively search all levels Only to this level

<SERVLET> Tag Sample

This page demonstrates the use of the <SERVLET> tag and runs the SnoopServlet in a table.


©1997 Live Software, Inc., All rights reserved.