I am using jsp to develop a web application…using tomcat server…
I am facing a bit problem in creating the web.xml file….what confusion i am having is that can an application have more than one web.xml file(obviously with a different name)? and what actually does the web.xml file does…..
in the tomcat webapp directory there is already a web.xml file…when i am making another application so should this file be delted or do i have to edit it or can i just use another one??
have got many more questions but i will appear confusing so will do the edit after i get an answer..
i am new to web development and this thing just struck me now….
would highly appreciate any help….
answer can be as basic as possible or to say make me understand as i m 10 year old..
Duplicate of this
See also here
The web.xml that is included in tomcat is for global settings. For basic demo applications that you are running on you local machine no need to touch it.
Each web application that you deploy will have it’s own web.xml file. This file is what tells the application server (in your case tomcat) a little about the application.
For example the name of you application.
When someone accesses the server http://localhost:8080/ where should the request be directed. Which java file should be given the responsibility to handle it. The web.xml defines a high level path. For example if your web.xml defines the name of your application as “myApp” then all requests directed to http://localhost:8080/myApp will be directed to be handled by myApp. The web.xml all defines the default page, and session timeout if different than global settings.
After that the myApp web.xml file will define all the servlets (the java code that is capable of handling web requests) along with what filters and listeners should be invoked along the way. You can define in your web.xml that all requests with the suffix “jsp” will be handled by a DispatchServlet, and all requests that end in “jsf” will be handled by a JsfServlet, or whatever.
If you are using a framework like Spring or JSF or whatever, they usually come with instructions on how to set up the web.xml and then after that you can pretty much forget about it.