rwsf::ServletContextrwsf::HandleBase
#include rwsf/servlet/ServletContext.h
rwsf::ServletContext represents the web application context. The Agent constructs a single context object for each web application. 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 following table lists methods that are either non-standard or not supported at this release.
getRequestDispatcher() |
Accepts an HTTP URL. This is an extension to the specification. |
getResource() |
Not included in this implementation. Use getResourceData() from rwsf::ServletContext instead. |
getResourceData() |
HydraExpress added this method as a safer alternative for C++ than the getResourceAsStream() method. |
getResourceAsStream() |
Not included in this implementation. Use getResourceData() from rwsf::ServletContext instead. |
ServletContext();
Creates an empty servlet context. Use the copy constructor or assignment operator to create a valid servlet context.
ServletContext(const ServletContext & second);
Attaches to and increments the reference count on second's body.
virtual ~ServletContext();
Detaches from the current body (if any), decrements its reference count, deletes it if there are no other references.
rwsf::Attribute 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 > getAttributeNames() const;
Returns an enumeration of all attribute names in this context. If there are no attributes, returns an empty enumeration.
ServletContext getContext(const std::string & contextName) const;
Returns the servlet context associated with the given URI.
std::string getContextPath() const;
Returns the local path to the context directory.
std::string 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 > getInitParameterNames() const;
Returns an enumeration of all context level initialization parameter names. If there are no initialization parameters, the enumeration will be empty.
int getMajorVersion() const;
Returns 2, the major version of the servlet API that the Agent supports.
std::string 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 getMinorVersion() const;
Returns 3, the minor version of the servlet API that the Agent supports.
rwsf::RequestDispatcher 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 getRealPath(const std::string & path) const;
Returns the full operating system specific path to the resource specified in path.
rwsf::RequestDispatcher 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 getResourceData(const std::string & path) const;
Returns the named resource as a string. This method takes care to clean up any resources that may have been allocated when loading the named resource.
rwsf::Enumeration< std::string > getResourcePaths(const std::string & path) const;
Returns a set of all paths in the web application.
std::string getServerInfo() const;
Returns the server identification string.
std::string getServletContextName() const;
Returns the name of this servlet context as defined by the directory in which the context has been deployed.
void log(const std::string & message) const;
Writes message to a servlet log file.
void log(const std::string & message, const rwsf::Exception & e) const;
Writes message and the string returned by e.why() to a servlet log file.
rwsf::Attribute removeAttribute(const std::string & name);
Removes the named attribute 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 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 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.
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 second 's body and increments its reference count.
© Copyright Rogue Wave Software, Inc. All Rights Reserved. All Rights Reserved. Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. HydraExpress is a trademark of Rogue Wave Software, Inc. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.