0

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..

1 Answers1

1

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.

Community
  • 1
  • 1
Danny C
  • 2,980
  • 2
  • 28
  • 20
  • the query which i had i the web application i am deploying has a web.xml file....where should i be keeping it in tomcat directory as the name will be coinciding with the name of the web.xml fiel of tomcat??? – Abhimanyu Srivastava Jun 21 '11 at 09:04
  • The web.xml that comes with tomcat is located in the conf folder. Your application's web.xml will inside your WEB-INF folder inside your application. Your application is placed in the webapps folder of tomcat. – Danny C Jun 21 '11 at 09:14
  • @danny....I was able to get my application running but i didn't change the xml file of the application and frankly speaking i havent even located it till now...how does dis happen? – Abhimanyu Srivastava Jun 21 '11 at 09:40
  • A few possibilities depending on what you are using. Most likely you are using an IDE (like Eclipse or Netbeans) and a wizard provided the basic setup for you. Or if you are using maven and a archetype that will also have created one for you. 3rd possibility if you are using a framework like GWT, SpringMVC, Wicket, etc. the setup came prepackaged. – Danny C Jun 27 '11 at 08:07