Servertec iws
Content
Introduction
Release Notes
Features
FAQs
Requirements
Installation
Add-ons
How To
Change Log
Future Plans
Knowledge Base
Documentation
Conventions
Command Line
Administrator
Localization
Programming
Security
Performance
Deployment
Java API
AccessLogEntry
Codecs
Connection
ConnectionPool...
DString
ErrorLogEntry
EventLogEntry
FileCache
FileUpload
IOHandler
IOManager
iws
Logger
MonitorEvent...
MultiPartForm
QuickSort
Realm
RealmAdmin...
RealmManager
ServletContextImpl
ServletContext...
ServletImpl
ServletManager
SocketHandler
Utils

Servlet API
CGI
SSI
Servlets
Config Files
Log Files
Classes
Directory Tree
Samples
Legal
Contact Us

 

java.lang.Object
 |
 +--stec.iws.iws

public final class iws

Methods used to initialize, run and stop the server.

Fields

Field Description
aliases Used to access, add, remove and change aliases.
hosts Used to access, add, remove and change virtual hosts.
locales Used to access, add, remove and change locales.
messages Used to access, add, remove and change messages.
mimetypes Used to access, add, remove and change mimetypes.
realms Used to access, add, remove and change realms.
resources Used to access, add, remove and change resources.
servlets Used to access, add, remove and change servlets.
servlet_contexts Used to access, add, remove and change servlet contexts.

Methods

Method Description
destroy Stops the server's runtime environment.
getBaseDirectory Returns the base directory or archive that the server uses to run from.
getConfigDirectory Returns the directory or archive path that the server uses to load configuration files from.
getDefaultCharset Returns the specified default character encoding.
getDefaultContentEncoding Returns the specified default content encoding.
getDefaultContentType Returns the specified default content type.
getDefaultLanguage Returns the specified default language.
getDefaultLocale Returns the specified default locale or the platform's default locale.
getFileEncoding Returns the specified file encoding or the platform's default file encoding.
getMimeType Returns the MIME type of the specified file.
getRealPath Returns the real path for the specified path.
getServerVersion Returns the current version of the server.
getShutdownCode Returns the numeric code specified when shutdown() was called.
getStartTime Returns the time in milliseconds since January 1, 1970 UTC when the server was started.
getTemplatesDirectory Returns the directory or archive path that the server uses to load templates from.
getWorkDirectory Returns the path to the given work directory.
init Initializes the server's runtime environment.
isContentNegotiated Returns whether content negotiation is enabled.
log Used to log exceptions or errors messages.
run Starts and run the server.
shutdown Returns whether the server is being shut down. A second form is used by the administration thread to shut down the server.

Example


import stec.iws.iws;
import stec.iws.ServletManager;
import stec.iws.ServletContextImpl;

public class testServer
{
  void static main(String[] args)
  {
    try
    {
      iws.init(args);

      iws.servlets.put("File", "stec.iws.FileServlet");

      ServletContextImpl context = 
          ServletManager.getServletContext("/");

      ServletManager.loadServlet(context, "File");

      iws.run();
    }
    catch(Exception ex)
    {
      log(ex);
    }
    finally
    {
      iws.destroy();
    }
  }
}

aliases

Used to access, add, remove and change aliases.

Syntax

public static Hashtable aliases

Notes

Aliases are automatically loaded when iws.init() is called.

Example

iws.aliases.put("/scripts", "/cgi-bin")

hosts

Used to access, add, remove and change virtual hosts.

Syntax

public static Hashtable hosts

Notes

Hosts are automatically loaded when iws.init() is called.

Example

iws.hosts.put("iob", "./servers/iob")

locales

Used to access, add, remove and change locales.

Syntax

public static Hashtable locales

Notes

Locales are automatically loaded when iws.init() is called.

Example

iws.locales.put("*", "ISO-8859-1")

messages

Used to access, add, remove and change messages.

Syntax

public static Hashtable messages

Notes

Messages are automatically loaded when iws.init() is called.

Example

iws.messages.put("200", "200 OK")

mimetypes

Used to access, add, remove and change mimetypes.

Syntax

public static Hashtable mimetypes

Notes

Mimetypes are automatically loaded when iws.init() is called.

Example

iws.mimetypes.put(".htm", "text/html")

realms

Used to access, add, remove and change realms.

Syntax

public static Hashtable realms

Notes

Realms are automatically loaded when iws.init() is called.

Example

iws.realms.put("default", "stec.iws.FileRealm")

resources

Used to access, add, remove and change resources.

Syntax

public static Hashtable resources

Notes

Resources are automatically loaded when iws.init() is called.

Example

iws.resources.put("/protected", "default")

servlets

Used to access, add, remove and change servlets.

Syntax

public static Hashtable servlets

Notes

Servlets are automatically loaded when iws.init() is called.

Example

iws.servlets.put("FileServlet", "stec.iws.FileServlet")

servlet_contexts

Used to access, add, remove and change servlet contexts.

Syntax

public static Hashtable servlet_contexts

Notes

Servlet Contexts are automatically loaded when iws.init() is called.

Example

iws.servlet_contexts.put("/accounting", "retries=5&timeout=10000")

destroy

Stops the server's runtime environment.

Syntax

public final static void destroy()

Parameters

None

Returns

Nothing

Throws

Nothing

Example

iws.destroy();

getBaseDirectory

Returns the base directory or archive that the server uses to run from.

Syntax

public final static String getBaseDirectory()

Parameters

None

Returns

String the base directory or archive file.

Throws

Nothing

Example

String base_dir = iws.getBaseDirectory();

getConfigDirectory

Returns the directory or archive path that the server uses to load configuration files from.

Syntax

public final static String getConfigDirectory()

Parameters

None

Returns

String the directory or archive path that the server uses to load configuration files from.

Throws

Nothing

Example

String config_dir = iws.getConfigDirectory();

getDefaultCharset

Returns the specified default character encoding.

Syntax

public final static String getDefaultCharset()

Parameters

None

Returns

String the specified default character encoding.

null if none was specified.

Throws

Nothing

Example

String charset = iws.getDefaultCharset();

getDefaultContentEncoding

Returns the specified default content encoding.

Syntax

public final static String[] getDefaultContentEncoding()

Parameters

None

Returns

String[] the specified default content encoding.

The first element contains the content encoding and the second element contains the file extension.

null if none was specified.

Throws

Nothing

Example

String charset = iws.getDefaultContentEncoding();

getDefaultContentType

Returns the specified default content type.

Syntax

public final static String[] getDefaultContentType()

Parameters

None

Returns

String[] the specified default content type.

The first element contains the content type and the second element contains the file extension.

null if none was specified.

Throws

Nothing

Example

String charset = iws.getDefaultContentType();

getDefaultLanguage

Returns the specified default language.

Syntax

public final static String getDefaultLanguage()

Parameters

None

Returns

String the specified default language.

null if none was specified.

Throws

Nothing

Example

String language = iws.getDefaultLanguage();

getDefaultLocale

Returns the specified default locale or the platform's default locale.

Syntax

public final static Locale getDefaultLocale()

Parameters

None

Returns

java.util.Locale the specified default locale or the platform's default locale.

Throws

Nothing

Example

Locale locale = iws.getDefaultLocale();

getFileEncoding

Returns the specified file encoding or the platform's default file encoding.

Syntax

public final static String getFileEncoding()

Parameters

None

Returns

String the specified file encoding or the platform's default file encoding.

Throws

Nothing

Example

String encoding = iws.getFileEncoding();

getMimeType

Returns the MIME type of the specified file.

Syntax

public final static String getMimeType(String filename)

Parameters

filename the filename to use.

Returns

String the associated mime type.

Throws

Nothing

Notes

A files MIME, Multipurpose Internet Mail Extension, type is a Web protocol for defining a files type.

Example

String mimetype = iws.getMimeType(filename);

getRealPath

Returns the real path for the specified path.

Syntax

public final static String getRealPath(String path)
                                            throws IOException

Parameters

path the path to use.

Returns

String the real path.

Throws

IOException any IO exception thrown.

Example

String path = iws.getRealPath("./workdir");

getServerVersion

Returns the current version of the server.

Syntax

public final static String getServerVersion()

Parameters

None

Returns

String the current version of the server.

Throws

Nothing

Example

String version = iws.getServerVersion();

getShutdownCode

Returns the numeric code specified when shutdown() was called.

Syntax

public final static int getShutdownCode()

Parameters

None

Returns

int the numeric code specified when shutdown was called.

0 to stop the server or 0x7fff to restart the server.

Throws

Nothing

Example

int shutdown_code = iws.getShutdownCode();

getStartTime

Returns the time in milliseconds since January 1, 1970 UTC when the server was started.

Syntax

public final static long getStartTime()

Parameters

None

Returns

long the time in milliseconds since January 1, 1970 UTC when the server was started.

Throws

Nothing

Example

long start_time = iws.getStartTime();

getTemplatesDirectory

Returns the directory or archive path that the server uses to load templates files from.

Syntax

public final static String getTemplatesDirectory()

Parameters

None

Returns

String the directory or archive path that the server uses to load templates files from.

Throws

Nothing

Example

String config_dir = iws.getTemplatesDirectory();

getWorkDirectory

Returns the path to the given work directory.

Syntax

public final static String getWorkDirectory(String path)
                                            throws IOException

Parameters

path the working directory.

Returns

String the absolute path to the working directory.

Throws

IOException any IO exception thrown.

Notes

If the specified path is a relative path then the work directory is relative to the server's base directory.

If the work directory does not exists then it will be created.

Example

String workdir = iws.getWorkDirectory("./upload");

init

Initializes the server's runtime environment.

Syntax

public final static void init(String[] args) throws Exception

Parameters

args an array of strings containing arguments used during the initialization of the server's runtime environment.

Returns

Nothing

Throws

Nothing

Notes

Presently the only parameter is an optional base directory that the server uses to find its configuration files.

Example

iws.init(args);

isContentNegotiated

Returns whether content negotiation is enabled.

Syntax

public final static boolean isContentNegotiated()

Parameters

None

Returns

boolean whether content negotiation is enabled.

Throws

Nothing

Example

boolean negotiate = iws.isContentNegotiated();

log

Used to log exceptions or errors messages.

Syntax

public final static void log(Throwable exception)
public final static void log(String message)
public final static void log(Throwable exception, String message)

Parameters

exception an Error or Exception object.
message event message to log.

Returns

Nothing

Throws

Nothing

Example

iws.destroy();

run

Starts and run the server.

Syntax

public final static void run() throws Exception

Parameters

None

Returns

Nothing

Throws

any exception thrown.

Example

iws.run();

shutdown

Returns whether the server is being shut down. A second form is used by the administration thread to shut down the server.

Syntax

public final static boolean shutdown()
public final static void shutdown(int shutdown_code)

Parameters

shutdown_code the numeric code returned to the iws wrapper.

0 to stop the server or 0x7fff to restart the server.

Returns

boolean whether the server is being shut down.

Throws

Nothing

Example

iws.shutdown(0);
 top of page
Copyright © 1998-2005 Servertec. All rights reserved.
Privacy Statement.
Last Modified: Sun Sep 04 14:56:49 EDT 2005