Understanding The Java Structure

by Master Mind | 1:53 AM in |

Web Applications use a standard directory structure defined in the Servlet specification. When developing web applications on J2EE platform, you must follow this structure so that application can be deployed in any J2EE compliant web server.

A web application has the following directory structure @TODO INSERT IMAGE OF DIRECTORY STRUCTURE

The root directory of the application is called the document root. Root directory is mapped to the context path. Root directory contains a directory named WEB-INF. Anything under the root directory excepting the WEB-INF directory is publically available, and can be accessed by URL from browser. WEB-INF directory is a private area of the web application, any files under WEB-INF directory cannot be accessed directly from browser by specifying the URL like http://somesite/WEB-INF/someresource.html. Web container will not serve the content of this directory. However the content of the WEB-INF directory is accessible by the classes within the application. So if there are any resources like JSPs or HTML document that you don’t wish to be accessible directly from web browser, you should place it under WEB-INF directory.
WEB-INF directory contains

* WEB-INF/web.xml deployment descriptor
* WEB-INF/classes directory
* WEB-INF/lib directory

The classes directory is used to store compiled servlet and other classes of the application. lib directory is used to store the jar files. If application has any bundled jar files, or if application uses any third party libraries such as log4j which is packaged in jar file, than these jar files should be placed in lib directory. All unpacked classes and resources in the /WEB-INF/classes directory, plus classes and resources in JAR files under the /WEB-INF/lib directory, are made visible to the containing web application.
Note: directory and file names are case sensitive.

0 comments: