Web Foundation (i)----Web applications and XML

Source: Internet
Author: User
Tags java web root directory


Web-inf new Two folders: Classes and LIB, the two folders are exactly the same: All Java class files needed to save the Web app, except that classes saves a single *.class file, and Lib saves the packaged jar file.



For Java Web Apps, Web-inf is a special folder, and the WEB container contains the contents of that folder, and the client browser cannot access anything under the Web-inf path.



Before the Servlet2.5 specification, the Java Most of the components of a Web application are configured for management through the. xml file, starting with Servlet3.0 or by configuring the management Web Component with annotations, so the XML. config file becomes more concise, which is also an important simplification for Servlet3.0.



Each Web container will provide a system. xml file that describes the common configuration properties for all Web applications.



A good, clear directory structure can be convenient for future maintenance, can help maintenance personnel quickly locate to the code file;



1.WEB Program Structure



1) A Web application consists of a set of Servlets, HTML pages, classes, and other resources that run on a Web server as a complete application, in a structured, hierarchical directory;



2) The files that make up the Web application are deployed in the appropriate directory hierarchy, and the root directory represents the "root" of the entire Web application;



3) Usually the directory of the Web application is placed in the WebApps directory, each subdirectory under the WebApps directory is a standalone Web application, the name of the subdirectory is the name of the Web application, which is the "root" of the Web application. The user accesses the resources in the Web application through the root of the Web application.



4) One example: The directory hierarchy of the Web application defined by the servlet specification



Note:

① Both the classes and LIB directories in the web-inf directory can hold Java class files, and when the servlet container runs, the WEB application's ClassLoader will first load the classes directory, followed by the classes in the Lib directory. If a class with the same name exists under both directories, the class that will work is the classes directory



②web-inf is a special directory (all letters are capitalized). This directory is not part of the context path that the Web application can access, which is not visible to the client. However, the contents of this directory are visible to the servlet code



The standard Java EE specification requires that the WebApp must have a directory named Web-inf, resources outside the directory, the user is directly accessible through the browser, all resources located in the directory, the user through the browser is inaccessible, But an internal servlet can be called. So many MVC frameworks (such as: SPRINGMVC) advocate that JSP files are protected under the Web-inf directory, and all JSP accesses are redirected through the servlet.





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.