Open the project's Web. xml file by adding two elements (<servlet-mapping> and <servlet >) to map the URL of the user access to the servlet.
Where <servlet-mapping> maps the user access to the URL to the servlet's internal name, the <servlet > element maps the servlet internal name to a servlet class name (package name + class name).
<servlet> <servlet-name>HttpServletTest</servlet-name> <servlet-class> Com.sss.httpservlettest</servlet-class></servlet>
Name: Specifies the name of the servlet, which must be unique within the same Web application.
Class: Specifies a class name (package name + class name)
==============================================================================================
<servlet-mapping> <servlet-name>HttpServletTest</servlet-name> <url-pattern>/ Httpservlettest</url-pattern></servlet-mapping>
Name: Must be the same as the name declared in the <servlet> element
Url-pattern: This address is the same as the requested address in the Web page
Note: After configuring a servlet-URL mapping, when the servlet container receives a request, first determine which Web application responds to the request, and then match the path of the request to the path of the servlet map.
===========================================================================================
Get initialization parameters
When you configure a servlet in Web. XML, you can configure some initialization parameters. In the servlet, these parameters can be obtained through the methods provided by the ServletConfig interface.
To set the initialization parameters of a servlet by adding <init-param> elements to the <servlet> element
1. Settings
<servlet> <init-param> <param-name></param-name> <param-value></ param-value> </init-param> </servlet>
Name: Name of parameter
Value: Values
2. Get initialization parameters
This.getinitparameter ("name"); À returns a string type
Name: Represents the name of the initialization parameter defined in the servlet.
"Javaweb Notes" Deployment Srevlet