servletcontainer.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef CSERVIMPLSERVLETCONTAINER_H
00021 #define CSERVIMPLSERVLETCONTAINER_H
00022
00023 #include <string>
00024 #include <ServletConfigImpl.h>
00025 #include <servlet/Servlet.h>
00026 #include <connection.h>
00027 #include <HttpSessionImpl.h>
00028
00029 #include <servlet/RequestDispatcher.h>
00030 #include <servlet/HttpServlet.h>
00031
00032
00033 namespace servlet {
00034 class Traceable;
00035 }
00036
00037 namespace container {
00038
00044 class ServletContainer: public servlet::RequestDispatcher
00045 {
00046 public:
00047 ServletContainer(servlet::Servlet*, container::ServletConfigImpl* conf,
00048 const std::string& path, size_t maxRequestSize, size_t maxFileSize,
00049 const std::string& mime, const std::string& enc, bool cache);
00050 ~ServletContainer();
00051
00055 std::string getName() const
00056 {
00057 return getConfig()->getServletName();
00058 }
00059
00063 const std::string& getPath() const
00064 {
00065 return m_path;
00066 }
00067
00072 void init()
00073 {
00074 m_servlet->init(*m_conf);
00075 }
00076
00081 void destroy()
00082 {
00083 m_servlet->destroy();
00084 }
00085
00089 container::ServletConfigImpl* getConfig() {return m_conf;}
00090 const container::ServletConfigImpl* getConfig() const {return m_conf;}
00091
00092 virtual void forward(servlet::ServletRequest& request, servlet::ServletResponse& response) const;
00093 virtual void include(servlet::ServletRequest& request, servlet::ServletResponse& response) const;
00094 private:
00095 servlet::Servlet* m_servlet;
00096 container::ServletConfigImpl* m_conf;
00097 std::string m_path;
00098 size_t m_maxRequestSize;
00099 size_t m_maxFileSize;
00100 std::string m_mime;
00101 std::string m_enc;
00102 bool m_cache;
00103 private:
00104 void invalidRequest(std::ostream& con, servlet::Traceable& e);
00105 void invalidRequest(std::ostream& con);
00106 protected:
00107 void service(Connection& con);
00108 private:
00109 friend class RequestHandler;
00110 };
00111
00112 }
00113
00114 #endif