0

I'm using Eclipse to create some basic jsp files with the help of Tomcat, and I was able to run and render a jsp file (on Mozilla Firefox), but then I read that one also should have a "deployment descriptor" file (web.xml), in order to "tell the application container how the web app should be configured".

I don't remember creating one, and I checked to see if Eclipse created a default one for me but couldn't find in anywhere in my project files...

Do I have to provide it, or is it just optional?

Sandeep Chatterjee
  • 3,220
  • 9
  • 31
  • 47
so.very.tired
  • 2,958
  • 4
  • 41
  • 69
  • 1
    In servlets 2.5 you have to provide a web.xml, in servlets 3.0 it is optional and you can replace it with annotations. For more details check [this answer in another question](http://stackoverflow.com/a/18187372/2164109) – morgano Aug 03 '14 at 09:33
  • According to Servlet Specification Version 2.5: **A web application is NOT required to contain a web.xml if it does NOT contain any Servlet, Filter, or Listener components. In other words an application containing only static files or JSP pages does not require a web.xml to be present.** – Sandeep Chatterjee Aug 03 '14 at 09:37

2 Answers2

2

if you don't use deployment descriptor you have to use annotations in your classes which are supported in servlet 3.0 and higher

Super Hornet
  • 2,839
  • 5
  • 27
  • 55
0

No it's not optional it is required to have a deployment descriptor in your deployed project. Since the deployment descriptor tells the application container how the web app should be configured.

mkazma
  • 572
  • 3
  • 11
  • 29