Where is web.xml in Eclipse Dynamic Web Project
EclipseEclipse Problem Overview
In Eclipse I clicked File->New->Dynamic Web Project and I am following a tutorial for Jersey that now wants me to go and change something in web.xml file...but I can't even find this file. What is it I am doing wrong?
Eclipse Solutions
Solution 1 - Eclipse
When you create a Dynamic Web Project you have the option to automatically create the web.xml file. If you don't mark that, the eclipse doesn't create it...
So, you have to add a new web.xml file in the WEB-INF folder.
To add a web.xml click on Next
-> Next
instead of Finish
. You will find it on the final screen of the wizard.
Solution 2 - Eclipse
you can do it by Dynamic Web Project –> RightClick –> Java EE Tools –> Generate Deployment Descriptor Stub.
Solution 3 - Eclipse
If you don't see the web.xml file in WEB-INF folder,
**- Select Deployment Descriptor and right click on it.
- Then select the Generate Deployment Descriptor Stub**
Finally you get web.xml file.
Solution 4 - Eclipse
When you open Eclipse you should click File → New → Dynamic Web Project, and make sure you checked Generate web.xml
, as described above.
If you have already created the project, you should go to the WebContent/WEB-INF
folder, open web.xml
, and put the following lines:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>Application Name </display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
Solution 5 - Eclipse
Might be your project is not JEE nature, to do this Right Click -> Properties -> Project Facets and click Convert to facet and check dynamic web module and ok. Now you will be able to see Java EE Tools.
Solution 6 - Eclipse
Follow below steps to generate web.xml in Eclipse with existing Dynamic Web Project
- Right Click on Created Dynamic Web Project
- Mouse Over Java EE Tools
- Click on Generate Deployment Descriptor Stub
- Now you are able to see web.xml file on WEB-INF folder
Solution 7 - Eclipse
The web.xml file should be listed right below the last line in your screenshot and resides in WebContent/WEB-INF
. If it is missing you might have missed to check the "Generate web.xml deployment descriptor" option on the third page of the Dynamic web project wizard.
Solution 8 - Eclipse
If you missed to check the "generate web.xml" option when creating a new project, no worries If it is a Dynamic Web Project in your project right click on "Deployment Descriptor:...." and Click on "Generate Deployment Descriptor Stub" this will create a minimal /webapp/WEB-INF/web.xml.
Solution 9 - Eclipse
For gradle / maven project you can use src/main/webapp/WEB-INF folder by default:
- main
- - java
- - resources
- - webapp
- - - META-INF
- - - - context.xml
- - - WEB-INF
- - - - web.xml
Solution 10 - Eclipse
If your deployment descriptor tab is disabled, then click on update libraries it will also do your work. It will create. Xml file in Web content
Solution 11 - Eclipse
I think you are creating a project in the wrong way,I am going to post here in step by step
Step 1: File>>New>>Project>>Web>>Dynamic Web Project
Step 2: Enter Project Name>>Next>>Next>>
Step 3: Check the checkbox for Generate web.xml deployment descriptor
Step 4: Finish
Please follow this way you will get you web.xml file under WEB-INF folder
Solution 12 - Eclipse
You can try this: right-click on the project and select Java EE Tools
-> Generate Deployment Descriptor Stub
. web.xml should be generated.