Practical : 9
Subject : Advanced Java
Aim : Create Servlet file and study web descriptor file.
Java web applications use a deployment descriptor file to determine how URLs map to servlets, which URLs require authentication, and other information. This file is named web.xml, and resides in the app's WAR under the WEB-INF/ directory. web.xml is part of the servlet standard for web applications.
A web application's deployment descriptor describes the classes, resources and configuration of the application and how the web server uses them to serve web requests. When the web server receives a request for the application, it uses the deployment descriptor to map the URL of the request to the code that ought to handle the request.
The deployment descriptor is a file named web.xml. It resides in the app's WAR under the WEB-INF/ directory. The file is an XML file whose root element is <web-app>.
web.xml File :-
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee">
<servlet>
<servlet-name>WebServlet</servlet-name>
<servlet-class>WebServlet</servlet-class>
</servlet>
<welecome-file-list>
<welcome-file>MainPage.html</welcome-file>
<welcome-file>index.html</welcome-file>
</welecome-file-list>
<servlet-mapping>
<servlet-name>WebServlet</servlet-name>
<url-pattern>/WebServlet</url-pattern>
</servlet-mapping>
</web-app>
Here, above example of practical 7 it show from where the server url request redirect. here the Servlet class and name is WebServlet and and <url-pattern> tag map the /Servlet URL in Servlet and fetch result about URL.<url-pattern> parent tag is <servlet-mapping> and always start with <web-app> and end with</web-app>.
Text:
Java web applications use a deployment descriptor file to determine how URLs map to servlets, which URLs require authentication, and other information. This file is named web.xml, and resides in the app's WAR under the WEB-INF/ directory. web.xml is part of the servlet standard for web applications.
A web application's deployment descriptor describes the classes, resources and configuration of the application and how the web server uses them to serve web requests. When the web server receives a request for the application, it uses the deployment descriptor to map the URL of the request to the code that ought to handle the request.
The deployment descriptor is a file named web.xml. It resides in the app's WAR under the WEB-INF/ directory. The file is an XML file whose root element is <web-app>.
web.xml File :-
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee">
<servlet>
<servlet-name>WebServlet</servlet-name>
<servlet-class>WebServlet</servlet-class>
</servlet>
<welecome-file-list>
<welcome-file>MainPage.html</welcome-file>
<welcome-file>index.html</welcome-file>
</welecome-file-list>
<servlet-mapping>
<servlet-name>WebServlet</servlet-name>
<url-pattern>/WebServlet</url-pattern>
</servlet-mapping>
</web-app>
Here, above example of practical 7 it show from where the server url request redirect. here the Servlet class and name is WebServlet and and <url-pattern> tag map the /Servlet URL in Servlet and fetch result about URL.<url-pattern> parent tag is <servlet-mapping> and always start with <web-app> and end with</web-app>.
Sign up here with your email
ConversionConversion EmoticonEmoticon