rwlogo
HydraExpress 4.6

HydraExpress C++ API Reference Guide


   


Rogue Wave web site:  Home Page  |  Main Documentation Page

rwsf::ServletContext Class Reference
[Servlet]

Represents the context constructed by the Agent for each web application. More...

#include <rwsf/servlet/ServletContext.h>

Inheritance diagram for rwsf::ServletContext:
rwsf::HandleBase

List of all members.

Public Member Functions

 ServletContext ()
 ServletContext (const ServletContext &second)
virtual ~ServletContext ()
ServletContextoperator= (const ServletContext &rhs)
int getMajorVersion () const
int getMinorVersion () const
void log (const std::string &message) const
void log (const std::string &message, const rwsf::Exception &e) const
std::string getServerInfo () const
std::string getRealPath (const std::string &path) const
std::string getInitParameter (const std::string &name) const
rwsf::Enumeration< std::string > getInitParameterNames () const
rwsf::Enumeration< std::string > getResourcePaths (const std::string &path) const
rwsf::RequestDispatcher getRequestDispatcher (const std::string &path) const
rwsf::RequestDispatcher getNamedDispatcher (const std::string &name) const
std::string getContextPath () const
ServletContext getContext (const std::string &contextName) const
rwsf::Attribute getAttribute (const std::string &name) const
rwsf::Enumeration< std::string > getAttributeNames () const
void setAttribute (const std::string &name, const rwsf::Attribute &data)
rwsf::Attribute removeAttribute (const std::string &name)
std::string getServletContextName () const
std::string getMimeType (const std::string &ext) const
std::string getResourceData (const std::string &path) const
void setSessionTimeout (size_t timeout)


Detailed Description

rwsf::ServletContext represents the web application context. The Agent constructs a single context object for each web application. A C++ web application consists of any number of servlets, filters, listeners,and static Web pages. For more information on web applications, see Section 2.2.2, "Contexts," in the HydraExpress Servlet Development Guide.

Each context object contains application-wide initialization parameters, information about the deployment environment, and a collection of attributes. A context also provides factory methods for creating request dispatchers to redirect requests. A context can retrieve other context objects held by the server so objects in different applications can cooperate.

The behavior of the following functions is inconsistent with or not defined in the Java Servlet Specification v2.3.

getRequestDispatcher() Accepts an HTTP URL. This is an extension to the specification.
getResource() Not included in this implementation. Use getResourceData() instead.
getResourceData() Added as a safer alternative for C++ than the getResourceAsStream() method.
getResourceAsStream() Not included in this implementation. Use getResourceData() instead.

Constructor & Destructor Documentation

rwsf::ServletContext::ServletContext (  ) 

Creates an empty servlet context. Use the copy constructor or assignment operator to create a valid servlet context.

rwsf::ServletContext::ServletContext ( const ServletContext second  ) 

Creates a new ServletContext handle to the body instance of second.

virtual rwsf::ServletContext::~ServletContext (  )  [virtual]

Detaches from the current body (if any), decrements its reference count, and deletes it if there are no other references.


Member Function Documentation

rwsf::Attribute rwsf::ServletContext::getAttribute ( const std::string &  name  )  const

Returns the specified attribute. Attribute name comparisons are case sensitive. If the named attribute is not found, returns an empty attribute.

rwsf::Enumeration<std::string> rwsf::ServletContext::getAttributeNames (  )  const

Returns an enumeration of all attribute names in this context. If there are no attributes, returns an empty enumeration.

ServletContext rwsf::ServletContext::getContext ( const std::string &  contextName  )  const

Returns the servlet context associated with the given URI.

std::string rwsf::ServletContext::getContextPath (  )  const

Returns the local path to the context directory.

std::string rwsf::ServletContext::getInitParameter ( const std::string &  name  )  const

Returns the named servlet context init parameter. Servlet context init parameters are defined in the deployment descriptor. If the named parameter cannot be found, returns the empty string.

rwsf::Enumeration<std::string> rwsf::ServletContext::getInitParameterNames (  )  const

Returns an enumeration of all context-level initialization parameter names. If there are no initialization parameters, the enumeration is empty.

int rwsf::ServletContext::getMajorVersion (  )  const

Returns 2, the major version of the servlet API that the Agent supports.

std::string rwsf::ServletContext::getMimeType ( const std::string &  ext  )  const

Returns the appropriate MIME type for the named file. MIME types are configured in the global configuration file and also in the individual context configuration files.

int rwsf::ServletContext::getMinorVersion (  )  const

Returns 3, the minor version of the servlet API that the Agent supports.

rwsf::RequestDispatcher rwsf::ServletContext::getNamedDispatcher ( const std::string &  name  )  const

Returns a request dispatcher object for the named servlet. If the named servlet does not exist, returns an invalid rwsf::RequestDispatcher object.

std::string rwsf::ServletContext::getRealPath ( const std::string &  path  )  const

Returns the full operating system-specific path to the resource specified in path.

rwsf::RequestDispatcher rwsf::ServletContext::getRequestDispatcher ( const std::string &  path  )  const

Returns a request dispatcher object for the path specified. The path can indicate either a local path to a servlet within the same context, a local path to a static page within the same context, or a complete HTTP URL.

std::string rwsf::ServletContext::getResourceData ( const std::string &  path  )  const

Returns the named resource as a string, where the resource is the contents of the file located at path, and path is a relative path to the context path.

See also:
getContextPath().
rwsf::Enumeration<std::string> rwsf::ServletContext::getResourcePaths ( const std::string &  path  )  const

Returns a set of all paths in the web application.

std::string rwsf::ServletContext::getServerInfo (  )  const

Returns the server identification string.

std::string rwsf::ServletContext::getServletContextName (  )  const

Returns the name of this servlet context as defined by the directory in which the context has been deployed.

void rwsf::ServletContext::log ( const std::string &  message,
const rwsf::Exception e 
) const

Writes message and the string returned by e.why() to a servlet log file.

void rwsf::ServletContext::log ( const std::string &  message  )  const

Writes message to a servlet log file.

ServletContext& rwsf::ServletContext::operator= ( const ServletContext rhs  ) 

Detaches from the current body (if any), decrements its reference count, deletes it if there are no other references, and then attaches to body of rhs, and increments its reference count.

rwsf::Attribute rwsf::ServletContext::removeAttribute ( const std::string &  name  ) 

Removes the named attribute name from the servlet context. Returns the previous value. If the named attribute cannot be found, returns an empty attribute. Attribute names are case-sensitive. If there are any rwsf::ServletContextAttributeListener objects defined in the context web.xml file, the Agent notifies those listeners of this change.

void rwsf::ServletContext::setAttribute ( const std::string &  name,
const rwsf::Attribute data 
)

Sets the named attribute to the given value. If there are any rwsf::ServletContextAttributeListener objects defined in the context web.xml file, the Agent notifies those listeners of the change.

void rwsf::ServletContext::setSessionTimeout ( size_t  timeout  ) 

Sets the session timeout to timeout minutes. The Agent invalidates any sessions that have been inactive for longer than the session timeout value. A negative value indicates that sessions should never time out.


Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo are registered trademarks of Rogue Wave Software, and HydraExpress is a trademark of Rogue Wave Software. All other trademarks are the property of their respective owners.