<Servlet>
<Servlet-Name> helloworld </servlet-Name>
<Servlet-class> helloworld </servlet-class>
<Init-param>
<Param-Name> param1 </param-Name>
<Param-value> param1value </param-value>
</Init-param>
<Run-as>
<Description> security role for anonymous access </description>
<Role-Name> Tomcat </role-Name>
</Run-as>
</Servlet>
<Servlet-mapping>
<Servlet-Name> Snoop </servlet-Name>
<URL-pattern>/snoop </url-pattern>
</Servlet-mapping>
<Load-on-startup> 1 </load-on-startup>
Element description:
<Servlet> </servlet> is used to declare the data of a servlet, mainly including the following sub-elements:
<Servlet-Name> </servlet-Name> specifies the servlet name.
<Servlet-class> </servlet-class> specifies the servlet class name.
<JSP-File> </JSP-File> specifies the complete path of a JSP page on the web platform.
<Init-param> </init-param> is used to define parameters. Multiple init-Param parameters are allowed. Access the initialization parameters through the getinitparamenter (string name) method in the servlet class.
<Load-on-startup> </load-on-startup> specifies the servlet loading sequence when the web application starts.
When the value is positive or zero: The servlet container first loads the servlet with a small value, and then loads the servlet with a large value in sequence.
The value is negative or undefined: The servlet container will load it when the Web Client first accesses this servlet.
<Servlet-mapping> </servlet-mapping> defines the URL of the servlet, which contains two child elements.
<Servlet-Name> </servlet-Name> specifies the servlet name.
<URL-pattern> </url-pattern> specifies the URL of the servlet.