Questions tagged [web.xml]

The web.xml is the web deployment descriptor file of Java Servlet based web applications. It allows you to define, declare and configure the Servlet API based implementations in your web application, such as servlets, filters and listeners.

A deployment descriptor (DD) refers to a configuration file for an artifact that is deployed to some container/engine.

In the Java Platform, Enterprise Edition, a deployment descriptor describes how a component, module or application (such as a web application or enterprise application) should be deployed. It directs a deployment tool to deploy a module or application with specific container options, security settings and describes specific configuration requirements. XML is used for the syntax of these deployment descriptor files.

For web applications, the deployment descriptor must be called web.xml and must reside in the WEB-INF directory in the web application root.

Further Reading:

2074 questions
27
votes
3 answers

Whitelist security constraint in web.xml

I'm using Tomcat for my Struts2 application. The web.xml has certain entries as shown below: restricted methods /*
Mike
  • 7,606
  • 25
  • 65
  • 82
27
votes
2 answers

Why use a JSF ExceptionHandlerFactory instead of redirection?

All of the ExceptionHandlerFactory examples I have come across so far redirect a user to a viewExpired.jsf page in the event that a ViewExpiredException is caught: public class ViewExpiredExceptionExceptionHandler extends ExceptionHandlerWrapper { …
8bitjunkie
  • 12,793
  • 9
  • 57
  • 70
24
votes
5 answers

How to write a spring bean with a constructor that contains a list?

I have a list as follows: ArrayList handlers = new ArrayList<>(); handlers.add(new AARHandler()); handlers.add(new CERHandler()); handlers.add(new PPAHandler()); handlers.add(new STRHandler()); handlers.add(new…
Rory
  • 1,805
  • 7
  • 31
  • 45
24
votes
5 answers

What is a servlet's "display-name" for?

The element appears to be a valid sub-element of the element as per the Servlet 2.5 deployment descriptor XSD. That is, according to Eclipse's XML validator, this: FooServlet
Matt Ball
  • 354,903
  • 100
  • 647
  • 710
24
votes
1 answer

How do web.xml filters work? Can you have two filters map to all pages (/*) and specify the order?

I want to use Spring Security, and it says to map the filter to /***. But I already have a filter mapped to /*, which is the Tuckee URLRewrite filter. Is it possible to map two filters to the same thing, and also is there a way to specify the order…
Kyle
  • 21,377
  • 37
  • 113
  • 200
24
votes
1 answer

Spring MVC web app: application context starts twice

I'm working on a Spring MVC REST API. Everything works fine, which is great, but I noticed from the logs that every time I restart my app the applicationContext loads twice: once when tomcat loads the war file, and a second time when the web app is…
Hendrik
  • 1,355
  • 3
  • 11
  • 30
23
votes
10 answers

schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/beans/spring- beans-4.1.5.xsd

I get an error in spring-dispatcher.xml in eclipse as given below. schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/beans/spring- beans-4.1.5.xsd', because 1) could not find the document; 2) the document…
Shamseer
  • 682
  • 1
  • 11
  • 24
22
votes
1 answer

Custom 404 using Spring DispatcherServlet

I've set up web.xml as below. I also have an annotation-based controller, which takes in any URL pattern and then goes to the corresponding jsp (I've set that up in the -servlet.xml). However, If I go to a page that ends in .html (and whose jsp…
njdeveloper
  • 1,465
  • 3
  • 13
  • 16
22
votes
11 answers

Eclipse FeatureNotFoundException

I have built my project with maven All builds successful and eclipse properties generation is also successful But when I open the project in Eclipse 4, I am getting this error An internal error occurred during: "Loading descriptor for…
RaceBase
  • 18,428
  • 47
  • 141
  • 202
21
votes
4 answers

Order of loading contextConfigLocation in web.xml of Spring Servlet project

Suppose that I have a Spring Java project and I am trying to configure it as a web server servlet. Here is a stripped-down version of the web.xml file: contextConfigLocation
ecbrodie
  • 11,246
  • 21
  • 71
  • 120
21
votes
0 answers

Error in web.xml "Element -- is not allowed here"

I have a problem in my web.xml. I get the following errors element is not allowed here. Here is my web.xml:
user3612244
  • 211
  • 1
  • 2
  • 5
20
votes
7 answers

How to stop printing exception stack trace on Console?

I wrote a servlet to handle the exceptions occurring in my web app and mapped them in web.xml java.lang.Exception /exceptionHandler Here is what I…
Suresh Atta
  • 120,458
  • 37
  • 198
  • 307
19
votes
5 answers

How can I read context parameter/web.xml values in a non-servlet java file?

I've got a regular java file that I use to update and query a mysql database but I need to take configurable options in that file (like host name, password, etc) and put it in the web.xml file (or perhaps another file if that's an option, but…
Kirn
  • 524
  • 1
  • 6
  • 18
19
votes
4 answers

how to specify welcome-file-list in WebApplicationInitializer.onStartup()

Currently I have a web application where we are using web.xml to configure the application. The web.xml has welcome-file-list. ... home.html
user2032118
  • 455
  • 3
  • 6
  • 16
19
votes
2 answers

Multiple filters with same url mapping

Is it possible to use two filters that have the same url-mapping? TeeFilter filter1r TeeFilter
mosaad
  • 2,276
  • 5
  • 27
  • 49