#include <servletcontainer.h>
Public Member Functions | |
ServletContainer (servlet::Servlet *, container::ServletConfigImpl *conf, const std::string &path, size_t maxRequestSize, size_t maxFileSize, const std::string &mime, const std::string &enc, bool cache) | |
~ServletContainer () | |
std::string | getName () const |
const std::string & | getPath () const |
void | init () |
void | destroy () |
container::ServletConfigImpl * | getConfig () |
const container::ServletConfigImpl * | getConfig () const |
virtual void | forward (servlet::ServletRequest &request, servlet::ServletResponse &response) const |
virtual void | include (servlet::ServletRequest &request, servlet::ServletResponse &response) const |
Protected Member Functions | |
void | service (Connection &con) |
Private Member Functions | |
void | invalidRequest (std::ostream &con, servlet::Traceable &e) |
void | invalidRequest (std::ostream &con) |
Private Attributes | |
servlet::Servlet * | m_servlet |
container::ServletConfigImpl * | m_conf |
std::string | m_path |
size_t | m_maxRequestSize |
size_t | m_maxFileSize |
std::string | m_mime |
std::string | m_enc |
Default mime type for response. | |
bool | m_cache |
Default character encoding for response. | |
Friends | |
class | RequestHandler |
Definition at line 44 of file servletcontainer.h.
container::ServletContainer::ServletContainer | ( | servlet::Servlet * | servlet, | |
container::ServletConfigImpl * | conf, | |||
const std::string & | path, | |||
size_t | maxRequestSize, | |||
size_t | maxFileSize, | |||
const std::string & | mime, | |||
const std::string & | enc, | |||
bool | cache | |||
) |
Definition at line 33 of file servletcontainer.cpp.
container::ServletContainer::~ServletContainer | ( | ) |
container::ServletContainer::destroy | ( | ) | [inline] |
Calls servlet::Servlet::destroy()
Definition at line 81 of file servletcontainer.h.
References servlet::Servlet::destroy(), and m_servlet.
Referenced by container::serverconfig::AppContext::destroyServlet().
void container::ServletContainer::forward | ( | servlet::ServletRequest & | request, | |
servlet::ServletResponse & | response | |||
) | const [virtual] |
Forwards a request from a servlet to another resource (servlet, JSP file, or HTML file) on the server. This method allows one servlet to do preliminary processing of a request and another resource to generate the response.
For a RequestDispatcher
obtained via getRequestDispatcher()
, the ServletRequest
object has its path elements and parameters adjusted to match the path of the target resource.
forward
should be called before the response has been committed to the client (before response body output has been flushed). If the response already has been committed, this method throws an IllegalStateException
. Uncommitted output in the response buffer is automatically cleared before the forward.
The request and response parameters must be either the same objects as were passed to the calling servlet's service method or be subclasses of the servlet::ServletRequestWrapper or servlet::ServletResponseWrapper classes that wrap them.
request | a servlet::ServletRequest object that represents the request the client makes of the servlet | |
response | a servlet::ServletResponse object that represents the response the servlet returns to the client |
ServletException | if the target resource throws this exception | |
IOException | if the target resource throws this exception | |
IllegalStateException | if the response was already committed |
Implements servlet::RequestDispatcher.
Definition at line 56 of file servletcontainer.cpp.
References getConfig(), getName(), servlet::ServletResponse::getOutputStream(), getPath(), container::ServletConfigImpl::getServletContext(), container::serverconfig::AppContext::getServletContextName(), container::serverconfig::AppContext::getUriBase(), servlet::ServletResponse::isCommitted(), m_servlet, and servlet::Servlet::service().
const container::ServletConfigImpl* container::ServletContainer::getConfig | ( | ) | const [inline] |
container::ServletContainer::getConfig | ( | ) | [inline] |
Definition at line 89 of file servletcontainer.h.
References m_conf.
Referenced by forward(), getName(), and container::serverconfig::AppContext::unloadServlet().
container::ServletContainer::getName | ( | ) | const [inline] |
Definition at line 55 of file servletcontainer.h.
References getConfig(), and container::ServletConfigImpl::getServletName().
Referenced by forward().
container::ServletContainer::getPath | ( | ) | const [inline] |
void container::ServletContainer::include | ( | servlet::ServletRequest & | request, | |
servlet::ServletResponse & | response | |||
) | const [virtual] |
Includes the content of a resource (servlet, JSP page, HTML file) in the response. In essence, this method enables programmatic server-side includes.
The servlet::ServletResponse object has its path elements and parameters remain unchanged from the caller's. The included servlet cannot change the response status code or set headers; any attempt to make a change is ignored.
The request and response parameters must be either the same objects as were passed to the calling servlet's service method or be subclasses of the servlet::ServletRequestWrapper or servlet::ServletResponseWrapper classes that wrap them.
request | a servlet::ServletRequest object that contains the client's request | |
response | a servlet::ServletResponse object that contains the servlet's response |
ServletException | if the included resource throws this exception | |
IOException | if the included resource throws this exception |
Implements servlet::RequestDispatcher.
Definition at line 67 of file servletcontainer.cpp.
References m_servlet, and servlet::Servlet::service().
container::ServletContainer::init | ( | ) | [inline] |
Calls servlet::Servlet::init(servlet::ServletConfig&)
Definition at line 72 of file servletcontainer.h.
References servlet::Servlet::init(), m_conf, and m_servlet.
Referenced by container::serverconfig::AppContext::initServlet().
void container::ServletContainer::invalidRequest | ( | std::ostream & | con | ) | [private] |
Definition at line 81 of file servletcontainer.cpp.
References servlet::HttpServletResponse::SC_INTERNAL_SERVER_ERROR.
void container::ServletContainer::invalidRequest | ( | std::ostream & | con, | |
servlet::Traceable & | e | |||
) | [private] |
Definition at line 73 of file servletcontainer.cpp.
References servlet::Traceable::printStackTrace(), and servlet::HttpServletResponse::SC_INTERNAL_SERVER_ERROR.
Referenced by service().
void container::ServletContainer::service | ( | Connection & | con | ) | [protected] |
Sets up request and response objects and calls servlet's service method
Definition at line 92 of file servletcontainer.cpp.
References getPath(), container::ServletConfigImpl::getServletContext(), invalidRequest(), m_cache, m_conf, m_enc, m_maxFileSize, m_maxRequestSize, m_mime, m_servlet, servlet::Traceable::printStackTrace(), and servlet::Servlet::service().
Referenced by container::RequestHandler::taskFunction().
friend class RequestHandler [friend] |
Definition at line 109 of file servletcontainer.h.
bool container::ServletContainer::m_cache [private] |
Default character encoding for response.
Definition at line 102 of file servletcontainer.h.
Referenced by service().
std::string container::ServletContainer::m_enc [private] |
Default mime type for response.
Definition at line 101 of file servletcontainer.h.
Referenced by service().
size_t container::ServletContainer::m_maxFileSize [private] |
size_t container::ServletContainer::m_maxRequestSize [private] |
std::string container::ServletContainer::m_mime [private] |
std::string container::ServletContainer::m_path [private] |
Definition at line 95 of file servletcontainer.h.
Referenced by destroy(), forward(), include(), init(), service(), and ~ServletContainer().