Servlet specification defines a standard structure for web applications,So that the web application run on any server irrespective of vendor.

Procedure for assembling a web-application

  1. Create WEB-ROOT Directory(example e:\WebApp)
  2. Create WEB-INF directory Under WEB-ROOT directory.
  3. Under WEB-INF directory create the following two directories
    • lib(For storing jar files.)
    • classes(For storing java classes.)
  4. Copy the servlet class files under WEB-INF/classes.
  5. Provide the deployment describer(web.xml) in WEB-INF directory
  6. StructureOfWebapp

    1. Provide the static resources like HTML files, XML files, Image files,etc.. under WEB-ROOT directory or the sub directory of WEB-ROOT directory(except WEB-INF)
    2. Static resources are publicly accessible i.e end user can access these just by name across the web.
    3. Secured resources are not recommended to place within the WEB-ROOT directory.
    4. Inside WEB-ROOT , we have to maintain a folder named with WEB-INF.Until servlet 2.4 version this folder is mandatory,But from servlet 2.5 version this folder is optional.
    5. All the resources which are placed within the WEB-INF are not publicly accessible and can be used by web container to provide response.
    6. If we access any resource directly by it’s name present in WEB-INF ,we will get 404 status code.
      Example:http://localhost:8080/WebApp/WEB-INF/web.xml
    7. Secured resources should be placed within WEB-INF only.
    8. The classes which present in classes folder are by default available to the web container and hence it is not required to set classpath explicitly.
    9. We should place all dependency jar files under lib folder.
    10. For the required .class files web container always searches first in classes folder,if it is not available then only it will search in lib folder.
    11. All tld files , which are used by our web application must be placed within the WEB-INF either directly or in directly.