WebLogic Server 6.0 Code Examples, BEA Systems, Inc.

examples.servlets
Class PhoneServlet

java.lang.Object
  |
  +--javax.servlet.GenericServlet
        |
        +--javax.servlet.http.HttpServlet
              |
              +--examples.servlets.PhoneServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class PhoneServlet
extends javax.servlet.http.HttpServlet

The PhoneServlet example demonstrates processing data received from a form and reading data from a text file.

Build the Example

  1. Open a new command shell.

  2. Set up this development shell as described in Setting up Your Environment for Building and Running the Examples.

  3. Compile the servlet using the following command line:
      $ javac -d %EX_WEBAPP_CLASSES% PhoneServlet.java
  4. Copy the file PhoneServletExample.html, located in the samples/examples/servlets directory in your WebLogic Server installation, to the config/examples/applications/examplesWebApp directory in your WebLogic Server installation. This directory is the location of the publicly-available files of the examplesWebApp.

  5. Start WebLogic Server with the examples configuration.

Configure the Server

Make sure that the examplesWebApp is deployed on your server.

Run the Example

Use a web browser to load the following URL:
http://localhost:7001/examplesWebApp/PhoneServletExample.html

Notes

This example makes entries to the WebLogic Server log file as the servlets executes. The location and name of your WebLogic Server log file is defined in the WebLogic Server Administration Console.

This example uses a text file called phonelist, located in your WebLogic Server installation, in the samples/examples/servlets directory. This file contains the phone number data. This is the file's contents:

#
# phone list
#
John   x5555
Paul   x9999
George x8888
Ringo  x5556

There's More...

For more information on servlets, see Programming WebLogic HTTP Servlets.

Author:
Copyright (c) 1996-98 by WebLogic, Inc. All Rights Reserved., Copyright (c) 1999-2000 by BEA Systems, Inc. All Rights Reserved.

Constructor Summary
PhoneServlet()
           
 
Method Summary
 void init(javax.servlet.ServletConfig config)
           
 void service(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Implements the service method.
 
Methods inherited from class javax.servlet.http.HttpServlet
, doDelete, doGet, doOptions, doPost, doPut, doTrace, getLastModified, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PhoneServlet

public PhoneServlet()
Method Detail

init

public void init(javax.servlet.ServletConfig config)
          throws javax.servlet.ServletException
Overrides:
init in class javax.servlet.GenericServlet

service

public void service(javax.servlet.http.HttpServletRequest req,
                    javax.servlet.http.HttpServletResponse res)
             throws java.io.IOException
Implements the service method. If the query is for a specific person, this method returns their number; otherwise, it outputs the entire extensions list. An htmlKona servlet page is used to display the results.
Overrides:
service in class javax.servlet.http.HttpServlet

Documentation is available at
http://e-docs.bea.com/wls/docs60

Copyright © 2000 BEA Systems, Inc. All Rights Reserved.