How are web applications packaged in Java?

Answered

How are web applications packaged in Java?

Ninja Asked on 19th September 2018 in Servlet.
Add Comment
1 Answer(s)
Best answer

Web Applications are packaged into Web ARchive (WAR) file. A web application exists as a structured hierarchy of directories. The root of this hierarchy serves as the document root for files that are part of the application. The top-level directory of a web application is the document root of the application. The document root is where JSP pages, client-side classes and archives, and static web resources, such as html pages and images, are stored.

The document root contains a subdirectory named WEB-INF, which contains the following files and directories:

  • xml: The web application deployment descriptor
  • classes: A directory that contains server-side classes: Servlets and other utility classes
  • lib: A directory that contains JAR archives of libraries called by Servlets and other server side classes

If your web application does not contain any servlets, filter, or listener components then it does not need a web application deployment descriptor. In other words, if your web application only contains JSP pages and static files then you are not required to include a web.xml file. With Servlet 3.0 annotations, we can remove a lot of clutter from web.xml by configuring servlets, filters and listeners using annotations.

Ninja Answered on 19th September 2018.
Add Comment