class cppmicroservices::HttpServlet

Inherits from std::enable_shared_from_this< HttpServlet >

Subclassed by cppmicroservices::AbstractWebConsolePlugin

Public Functions

virtual void Init(const ServletConfig &config)

Called by the servlet container to indicate to a servlet that the servlet is being placed into service.

The servlet container calls the Init method exactly once after instantiating the servlet. The Init method must complete successfully before the servlet can receive any requests.

The servlet container cannot place the servlet into service if the Init method

  1. Throws a ServletException
  2. Does not return within a time period defined by the Web server

  • config: a ServletConfig object containing the servlet’s configuration and initialization parameters
  • ServletException: if an exception has occurred that interferes with the servlet’s normal operation

virtual void Destroy()

Called by the servlet container to indicate to a servlet that the servlet is being taken out of service.

This method is only called once all threads within the servlet’s service method have exited or after a timeout period has passed. After the servlet container calls this method, it will not call the service method again on this servlet.

This method gives the servlet an opportunity to clean up any resources that are being held (for example, memory, file handles, threads) and make sure that any persistent state is synchronized with the servlet’s current state in memory.

ServletConfig GetServletConfig() const

Returns a ServletConfig object, which contains initialization and startup parameters for this servlet.

The ServletConfig object returned is the one passed to the Init method.

the ServletConfig object that initializes this servlet

virtual void Service(HttpServletRequest &request, HttpServletResponse &response)
std::shared_ptr<ServletContext> GetServletContext() const
virtual ~HttpServlet()

Public Static Attributes

const std::string PROP_CONTEXT_ROOT

Protected Functions

virtual long long GetLastModified(HttpServletRequest &request)
virtual void DoGet(HttpServletRequest &request, HttpServletResponse &response)
virtual void DoHead(HttpServletRequest &request, HttpServletResponse &response)
virtual void DoDelete(HttpServletRequest &request, HttpServletResponse &response)
virtual void DoPost(HttpServletRequest &request, HttpServletResponse &response)
virtual void DoPut(HttpServletRequest &request, HttpServletResponse &response)
virtual void DoTrace(HttpServletRequest &request, HttpServletResponse &response)
std::unique_lock<std::mutex> Lock() const