- public class HttpServer
- extends Server
- implements java.lang.Runnable, javax.servlet.ServletContext
A standard multi-threaded HTTP web server such as the main web server
or the administration server.
Warning: the key field is used to store a unique identifier
and should not be modified.
HttpServer()
- Creates a new HTTP server.
flushLogs()
- Flushes the server's logs.
getAccessLogging()
- Returns true if access logging is enabled.
getAliases()
- Returns the server's list of aliases.
getAttribute(String)
- Returns the object bound to the specified name.
getAttributeNames()
- Returns an enumeration of the names of the attributes known to the server.
getErrorLogging()
- Returns true if error logging is enabled.
getHitLogging()
- Returns true if hit logging is enabled.
getHttpTimeout()
- Returns the server's HTTP transaction timeout setting.
getKeepAliveTimeout()
- Returns the server's keep-alive timeout setting.
getMaxThreads()
- Returns the server's maximum threads setting.
getMimeType(String)
- Returns the mime type of the specified file or null if not known.
getMinThreads()
- Returns the server's minimum threads setting.
getRealPath(String)
- Translates the specified alias into a real file name.
getRefererLogging()
- Returns true if referer logging is enabled.
getRequestDispatcher(String)
- Returns a request disptacher for the specified URI.
getResource(String)
- Returns a URL object that points to the corresponding URI.
getServerInfo()
- Returns the server name and version number.
getServlet(String)
- Returns the specified servlet.
getServletLogging()
- Returns true if servlet logging is enabled.
getServletNames()
- Returns an enumeration of the aliases of the servlets in this context (server).
getServlets()
- Returns an enumeration of the servlets in this context (server).
init()
- Performs the initialisation required after the configuration file
has been read.
kill()
- Kills the server.
log(Exception, String)
- Writes the specified message and exception to the servlet log file.
Deprecated
log(String)
- Writes the specified message to the servlet log file.
log(String, Throwable)
- Writes the specified message and stack trace to the servlet log.
periodic(long)
- Performs certain time-dependent tasks such as checking for
timed-out connections.
removeAttribute(String)
- Removes the specified attribute from the servlet context.
resetLogs(String)
- Resets the server's logs.
run()
- The server thread's run method.
save(vqos)
- Writes the server's configuration to the output stream specified in vqServer .cfg file format.
setAccessLogging(boolean)
- Enables or disables access logging.
setAttribute(String, Object)
- Binds the specified object to the specified name.
setErrorLogging(boolean)
- Enables or disables error logging.
setHitLogging(boolean)
- Enables or disables hit logging.
setHttpTimeout(long)
- Sets the server's HTTP transaction timeout setting.
setKeepAliveTimeout(long)
- Sets the server's keep-alive timeout setting.
setMaxThreads(int)
- Sets the server's maximum threads setting.
setMinThreads(int)
- Sets the server's minimum threads setting.
setPort(int)
- Sets the TCP/IP port on which the server listens for incoming
requests.
setRefererLogging(boolean)
- Enables or disables referer logging.
setServletLogging(boolean)
- Enables or disables servlet logging.
start()
- Starts the server.
stop()
- Stops the server.
HttpServer
public HttpServer()
Creates a new HTTP server.
init
public void init()
Performs the initialisation required after the configuration file
has been read.
- Overrides:
- init in class Server
kill
public void kill()
Kills the server.
Warning: do not invoke this method if the server
is a member of a list.
- Overrides:
- kill in class Server
save
public void save(vqos os) throws java.io.IOException
Writes the server's configuration to the output stream specified in vqServer .cfg file format.
- Overrides:
- save in class klentry
run
public void run()
The server thread's run method. It has to be public because of the
Runnable interface. Do not call this method.
flushLogs
public void flushLogs()
Flushes the server's logs.
- Overrides:
- flushLogs in class Server
resetLogs
public void resetLogs(java.lang.String theExtension)
Resets the server's logs.
- Overrides:
- resetLogs in class Server
setPort
public void setPort(int thePort)
Sets the TCP/IP port on which the server listens for incoming
requests. If the server is running it is first shut down and
then restarted. The log files are renamed.
- Overrides:
- setPort in class Server
getServlet
public javax.servlet.Servlet getServlet(java.lang.String servletAlias) throws javax.servlet.ServletException
Returns the specified servlet.
A ServletContext method.
- Parameters:
servletAlias
- an alias that maps to the servlet
- Returns:
- the Servlet or null if not found
- Throws:
- javax.servlet.ServletException - if the servlet could not be initialised
getServlets
public java.util.Enumeration getServlets()
Returns an enumeration of the servlets in this context (server).
The enumeration only includes initialised servlets.
A ServletContext method.
getServletNames
public java.util.Enumeration getServletNames()
Returns an enumeration of the aliases of the servlets in this context (server).
The enumeration only includes the names of initialised servlets.
A ServletContext method.
log
public void log(java.lang.String msg)
Writes the specified message to the servlet log file.
A ServletContext method.
log
public void log(java.lang.Exception e,
java.lang.String msg)
- Note: log() is deprecated.Replaced by log(String msg, Throwable t)
Writes the specified message and exception to the servlet log file.
A ServletContext method.
getRealPath
public java.lang.String getRealPath(java.lang.String theAlias)
Translates the specified alias into a real file name.
A ServletContext method.
getMimeType
public java.lang.String getMimeType(java.lang.String fileName)
Returns the mime type of the specified file or null if not known.
A ServletContext method.
getServerInfo
public java.lang.String getServerInfo()
Returns the server name and version number.
A ServletContext method.
setAttribute
public void setAttribute(java.lang.String name,
java.lang.Object object)
Binds the specified object to the specified name.
Attribute names are case insensitive in vqServer.
A ServletContext method (specification version 2.1).
removeAttribute
public void removeAttribute(java.lang.String name)
Removes the specified attribute from the servlet context.
Attribute names are case insensitive in vqServer.
A ServletContext method (specification version 2.1).
log
public void log(java.lang.String msg,
java.lang.Throwable t)
Writes the specified message and stack trace to the servlet log.
A ServletContext method (specification version 2.1).
getResource
public java.net.URL getResource(java.lang.String path) throws java.net.MalformedURLException
Returns a URL object that points to the corresponding URI.
A ServletContext method (specification version 2.1).
getAttributeNames
public java.util.Enumeration getAttributeNames()
Returns an enumeration of the names of the attributes known to the server.
A ServletContext method (specification version 2.1).
start
public void start()
Starts the server.
- Overrides:
- start in class Server
stop
public void stop()
Stops the server.
- Overrides:
- stop in class Server
periodic
public void periodic(long currentTime)
Performs certain time-dependent tasks such as checking for
timed-out connections.
Called periodically by the timer thread.
- Parameters:
currentTime
- the current time as returned by System.currentTimeMillis()
- Overrides:
- periodic in class Server
getMinThreads
public int getMinThreads()
Returns the server's minimum threads setting.
setMinThreads
public void setMinThreads(int newSetting)
Sets the server's minimum threads setting.
getMaxThreads
public int getMaxThreads()
Returns the server's maximum threads setting.
setMaxThreads
public void setMaxThreads(int newSetting)
Sets the server's maximum threads setting.
getHttpTimeout
public long getHttpTimeout()
Returns the server's HTTP transaction timeout setting.
setHttpTimeout
public void setHttpTimeout(long newSetting)
Sets the server's HTTP transaction timeout setting.
getKeepAliveTimeout
public long getKeepAliveTimeout()
Returns the server's keep-alive timeout setting.
setKeepAliveTimeout
public void setKeepAliveTimeout(long newSetting)
Sets the server's keep-alive timeout setting.
getAliases
public Aliases getAliases()
Returns the server's list of aliases.
getAccessLogging
public boolean getAccessLogging()
Returns true if access logging is enabled.
setAccessLogging
public boolean setAccessLogging(boolean newSetting)
Enables or disables access logging. Returns true if the setting was changed.
getErrorLogging
public boolean getErrorLogging()
Returns true if error logging is enabled.
setErrorLogging
public boolean setErrorLogging(boolean newSetting)
Enables or disables error logging. Returns true if the setting was changed.
getServletLogging
public boolean getServletLogging()
Returns true if servlet logging is enabled.
setServletLogging
public boolean setServletLogging(boolean newSetting)
Enables or disables servlet logging. Returns true if the setting was changed.
getHitLogging
public boolean getHitLogging()
Returns true if hit logging is enabled.
setHitLogging
public boolean setHitLogging(boolean newSetting)
Enables or disables hit logging. Returns true if the setting was changed.
getRefererLogging
public boolean getRefererLogging()
Returns true if referer logging is enabled.
setRefererLogging
public boolean setRefererLogging(boolean newSetting)
Enables or disables referer logging. Returns true if the setting was changed.
getRequestDispatcher
public javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String URI)
Returns a request disptacher for the specified URI.
A ServletContext method.
getAttribute
public java.lang.Object getAttribute(java.lang.String name)
Returns the object bound to the specified name.
Attribute names are case insensitive in vqServer.
A ServletContext method.