Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do we use web.xml? [closed]

What is the use of web.xml and why do we use?

<filter>         <filter-name>wicket.mysticpaste</filter-name>         <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>         <init-param>             <param-name>applicationClassName</param-name>             <param-value>com.mysticcoders.WicketApplication</param-value>         </init-param>     </filter>   <filter-mapping>   <filter-name>wicket.mysticpaste</filter-name>     <url-pattern>/*</url-pattern>  </filter-mapping> 

What does this filer and filermapping do?

like image 260
theJava Avatar asked Dec 27 '10 13:12

theJava


People also ask

What is the purpose of web xml?

web. xml defines mappings between URL paths and the servlets that handle requests with those paths. The web server uses this configuration to identify the servlet to handle a given request and call the class method that corresponds to the request method.

Do We Need web xml in spring boot?

xml file is required! When required, however, we can take control over parts of the configuration and override the conventions that Spring Boot puts in play. We can also, if we really must, use traditional XML configuration files for some parts of the configuration.

Is web xml necessary?

No, there will be no need of web. xml for servlet based application if you are using servlet version >3.0 and tomcat 7 as it will not run in the previous versions of tomcat. Annotation represents the metadata. If you use annotation, deployment descriptor (web.

What is the use of web xml in Spring MVC?

Application Configuration Spring MVC web applications use the web. xml file as a deployment descriptor file. Also, it defines mappings between URL paths and the servlets in the web.


1 Answers

Generally speaking, this is the configuration file of web applications in java. It instructs the servlet container (tomcat for ex.) which classes to load, what parameters to set in the context, and how to intercept requests coming from browsers.

There you specify:

  • what servlets (and filters) you want to use and what URLs you want to map them to
  • listeners - classes that are notified when some events happen (context starts, session created, etc)
  • configuration parameters (context-params)
  • error pages, welcome files
  • security constraints

In servlet 3.0 many of the web.xml parts are optional. These configurations can be done via annotations (@WebServlet, @WebListener)

like image 171
Bozho Avatar answered Oct 23 '22 05:10

Bozho