home *** CD-ROM | disk | FTP | other *** search
/ Java Developer's Companion / Java Developer's Companion.iso / binaries / Windows / jsdk / src / javax / servlet / ServletContext.java < prev    next >
Encoding:
Java Source  |  1997-07-18  |  4.1 KB  |  110 lines

  1. /*
  2.  * @(#)ServletContext.java    1.15 97/05/22
  3.  * 
  4.  * Copyright (c) 1995-1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  * CopyrightVersion 1.0
  20.  */
  21.  
  22. package javax.servlet;
  23.  
  24. import java.io.IOException;
  25. import java.util.Enumeration;
  26.  
  27. /**
  28.  * The ServletContext interface gives servlets access to information about
  29.  * their environment, and allows them to log significant events.  Servlet
  30.  * writers decide what data to log.  The interface is implemented by
  31.  * services, and used by servlets.  Different virtual hosts should have
  32.  * different servlet contexts.
  33.  *
  34.  * <p>Servlets get the ServletContext object via the getServletContext
  35.  * method of ServletConfig.  The ServletConfig object is provided to
  36.  * the servlet at initialization, and is accessible via the servlet's
  37.  * getServletConfig method.
  38.  *
  39.  * @see Servlet#getServletConfig
  40.  * @see ServletConfig#getServletContext
  41.  * @version     1.15, 05/22/97
  42.  * @author      David Connelly
  43.  * @author Pavani Diwanji
  44.  */
  45. public
  46. interface ServletContext {
  47.     /**
  48.      * Returns the servlet of the specified name, or null if not
  49.      * found.  When the servlet is returned it is initialized and
  50.      * ready to accept service requests.
  51.      *
  52.      * @param name the name of the desired servlet
  53.      * @exception ServletException if the servlet could not be initialized
  54.      */
  55.     public Servlet getServlet(String name) throws ServletException;
  56.  
  57.     /**
  58.      * Returns an enumeration of the Servlet objects in this server.
  59.      * Only servlets that are accessible (i.e., from the same namespace)
  60.      * will be returned.  The enumeration always includes the servlet
  61.      * itself.
  62.      */
  63.     public Enumeration getServlets();
  64.     
  65.     /**
  66.      * Writes the given message string to the servlet log file.
  67.      * The name of the servlet log file is server specific; it
  68.      * is normally an event log.
  69.      * @param msg the message to be written
  70.      */
  71.     public void log(String msg);
  72.  
  73.     /**
  74.      * Applies alias rules to the specified virtual path and returns the
  75.      * corresponding real path.  For example, in an HTTP servlet,
  76.      * this method would resolve the path against the HTTP service's
  77.      * docroot.  Returns null if virtual paths are not supported, or if the
  78.      * translation could not be performed for any reason.
  79.      * @param path the virtual path to be translated into a real path
  80.      */
  81.     public String getRealPath(String path);
  82.  
  83.     /**
  84.      * Returns the mime type of the specified file, or null if not known.
  85.      * @param file name of the file whose mime type is required
  86.      */
  87.     public String getMimeType(String file);
  88.  
  89.     /**
  90.      * Returns the name and version of the network service under which
  91.      * the servlet is running. Same as the CGI variable SERVER_SOFTWARE.
  92.      */
  93.     public String getServerInfo();
  94.  
  95.     /**
  96.      * Returns the value of the named attribute of the network service,
  97.      * or null if the attribute does not exist.  This method allows
  98.      * access to additional information about the service, not already
  99.      * provided by the other methods in this interface. Attribute names
  100.      * should follow the same convention as package names.  The package
  101.      * names java.* and javax.* are reserved for use by Javasoft, and
  102.      * com.sun.* is reserved for use by Sun Microsystems.
  103.      *
  104.      * @param name the name of the attribute whose value is required
  105.      * @return the value of the attribute, or null if the attribute
  106.      * does not exist.
  107.      */
  108.     public Object getAttribute(String name);
  109. }
  110.