SERVLET MAPPING
You can reach to
your servlet class from url with the mapping information. If you give url mapping
to your named servlet in web.xml file and if this named servlet is related with
the real path in web.xml then you can write custom url to the browser and you
can reach also you can type it in your program as variable.
For example you
opened a servlet in com.example as exampleServlet and you want to make it
associated with the http:/...:../ProjectName/{MyCustomServletName}
You should open
your web.xml and
<servlet>
<description>
</description>
<display-name>exampleServlet</display-name>
<servlet-name>exampleServlet</servlet-name>
<servlet-class>com.example.exampleServlet</servlet-class>
</servlet>
This will introduce your servlet to
the web application.
<servlet-mapping>
<servlet-name>exampleServlet</servlet-name>
<url-pattern>/exampleServletNow</url-pattern>
</servlet-mapping>
This maps your
url pattern with the servlet name defined as index in web.xml and this index
goes into <servlet> tags and searches the same of it. When the search
results successfully it returns the servlet-class that gives you the exact
builded class to your browser.If your project name is DynamicWebExample
Then you can type
as http:/localhost:8080/DynamicWebExample/exampleServletNow or whatever you wrote for mapping information.
No comments:
Post a Comment