Provides the Click application HttpServlet.
Generally developers will simply configure the
ClickServlet and will not use it directly in their code. For a Click web application to function the
ClickServlet must be configured in the web application's
/WEB-INF/web.xml file. A simple web application which maps all
*.htm requests to a ClickServlet is provided below.
<web-app> <servlet> <servlet-name>click-servlet</servlet-name> <servlet-class>org.apache.click.ClickServlet</servlet-class> <load-on-startup>0</load-on-startup> </servlet> <servlet-mapping> <servlet-name>click-servlet</servlet-name> <url-pattern>*.htm</url-pattern> </servlet-mapping> </web-app>
By default the
ClickServlet will attempt to load an application configuration file using the path:
/WEB-INF/click.xml Servlet Mapping
By convention all Click page templates should have a .htm extension, and the ClickServlet should be mapped to process all *.htm URL requests. With this convention you have all the static HTML pages use a .html extension and they will not be processed as Click pages.
Load On Startup
Note you should always set
load-on-startup element to be 0 so the servlet is initialized when the server is started. This will prevent any delay for the first client which uses the application.
The
ClickServlet performs as much work as possible at startup to improve performance later on. The Click start up and caching strategy is configured with the Click application mode in the "
click.xml" file. See the User Guide for information on how to configure the application mode.
ConfigService
A single application {@link ConfigService} instance is created by the ClickServlet atstartup. Once the ConfigService has been initialized it is stored in the ServletContext using the key {@value org.apache.click.service.ConfigService#CONTEXT_NAME}.